eslint-plugin-nextfriday 3.2.0 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +22 -0
- package/README.md +33 -61
- package/docs/agents/domain.md +51 -0
- package/docs/agents/issue-tracker.md +22 -0
- package/docs/agents/triage-labels.md +15 -0
- package/docs/rules/ENFORCE_CONSTANT_CASE.md +28 -17
- package/docs/rules/NO_INLINE_NESTED_OBJECT.md +45 -27
- package/docs/rules/PREFER_GUARD_CLAUSE.md +2 -0
- package/docs/rules/PREFER_IMPORT_TYPE.md +5 -0
- package/docs/rules/PREFER_INTERFACE_FOR_COMPONENT_PROPS.md +53 -0
- package/docs/rules/PREFER_NAMED_PARAM_TYPES.md +5 -1
- package/docs/rules/PREFER_PROPS_WITH_CHILDREN.md +112 -0
- package/lib/index.cjs +667 -757
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +92 -200
- package/lib/index.d.ts +92 -200
- package/lib/index.js +634 -724
- package/lib/index.js.map +1 -1
- package/package.json +1 -1
- package/docs/rules/ENFORCE_CURLY_NEWLINE.md +0 -55
- package/docs/rules/FILE_KEBAB_CASE.md +0 -70
- package/docs/rules/JSX_PASCAL_CASE.md +0 -71
- package/docs/rules/NEXTJS_REQUIRE_PUBLIC_ENV.md +0 -44
package/lib/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// package.json
|
|
2
2
|
var package_default = {
|
|
3
3
|
name: "eslint-plugin-nextfriday",
|
|
4
|
-
version: "
|
|
4
|
+
version: "4.0.0",
|
|
5
5
|
description: "A comprehensive ESLint plugin providing custom rules and configurations for Next Friday development workflows.",
|
|
6
6
|
keywords: [
|
|
7
7
|
"eslint",
|
|
@@ -397,6 +397,10 @@ import { basename, extname } from "path";
|
|
|
397
397
|
import { AST_NODE_TYPES as AST_NODE_TYPES3 } from "@typescript-eslint/utils";
|
|
398
398
|
var getFileExtension = (filename) => extname(filename).slice(1);
|
|
399
399
|
var getBaseName = (filename) => basename(filename, extname(filename));
|
|
400
|
+
var isJsxFile = (filename) => {
|
|
401
|
+
const ext = getFileExtension(filename);
|
|
402
|
+
return ext === "jsx" || ext === "tsx";
|
|
403
|
+
};
|
|
400
404
|
var isConfigFile = (filename) => {
|
|
401
405
|
const baseName = getBaseName(filename);
|
|
402
406
|
return /\.(config|rc|setup|spec|test)$/.test(baseName) || /\.(config|rc|setup|spec|test)\./.test(filename) || /^\.(eslintrc|babelrc|prettierrc)/.test(filename);
|
|
@@ -408,40 +412,14 @@ var createRule3 = ESLintUtils3.RuleCreator(
|
|
|
408
412
|
);
|
|
409
413
|
var SCREAMING_SNAKE_CASE_REGEX = /^[A-Z][A-Z0-9]*(?:_[A-Z0-9]+)*$/;
|
|
410
414
|
var SNAKE_CASE_REGEX2 = /^[a-z]+_[a-z0-9_]*$/;
|
|
411
|
-
var BOOLEAN_PREFIXES2 = ["is", "has", "should", "can", "did", "will", "was", "are", "does", "had"];
|
|
412
415
|
var toScreamingSnakeCase = (str) => str.replace(/([a-z])([A-Z])/g, "$1_$2").replace(/([A-Z])([A-Z][a-z])/g, "$1_$2").toUpperCase();
|
|
413
|
-
var
|
|
414
|
-
if (!name.startsWith(prefix)) {
|
|
415
|
-
return false;
|
|
416
|
-
}
|
|
417
|
-
if (name.length === prefix.length) {
|
|
418
|
-
return true;
|
|
419
|
-
}
|
|
420
|
-
const nextChar = name.charAt(prefix.length);
|
|
421
|
-
return nextChar === nextChar.toUpperCase() && nextChar !== nextChar.toLowerCase();
|
|
422
|
-
});
|
|
423
|
-
var isBooleanLiteral2 = (init) => init.type === AST_NODE_TYPES4.Literal && typeof init.value === "boolean";
|
|
424
|
-
var isAsConstAssertion = (node) => node.type === AST_NODE_TYPES4.TSAsExpression && node.typeAnnotation.type === AST_NODE_TYPES4.TSTypeReference && node.typeAnnotation.typeName.type === AST_NODE_TYPES4.Identifier && node.typeAnnotation.typeName.name === "const";
|
|
425
|
-
var isStaticValue2 = (init) => {
|
|
426
|
-
if (isAsConstAssertion(init)) {
|
|
427
|
-
return true;
|
|
428
|
-
}
|
|
416
|
+
var isMagicLiteral = (init) => {
|
|
429
417
|
if (init.type === AST_NODE_TYPES4.Literal) {
|
|
430
|
-
return
|
|
431
|
-
}
|
|
432
|
-
if (init.type === AST_NODE_TYPES4.UnaryExpression && init.argument.type === AST_NODE_TYPES4.Literal) {
|
|
433
|
-
return true;
|
|
434
|
-
}
|
|
435
|
-
if (init.type === AST_NODE_TYPES4.TemplateLiteral && init.expressions.length === 0) {
|
|
436
|
-
return true;
|
|
437
|
-
}
|
|
438
|
-
if (init.type === AST_NODE_TYPES4.ArrayExpression) {
|
|
439
|
-
return init.elements.every((el) => el !== null && el.type !== AST_NODE_TYPES4.SpreadElement && isStaticValue2(el));
|
|
418
|
+
return typeof init.value === "string" || typeof init.value === "number";
|
|
440
419
|
}
|
|
441
|
-
if (init.type === AST_NODE_TYPES4.
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
);
|
|
420
|
+
if (init.type === AST_NODE_TYPES4.UnaryExpression) {
|
|
421
|
+
const { argument, operator } = init;
|
|
422
|
+
return (operator === "-" || operator === "+") && argument.type === AST_NODE_TYPES4.Literal && typeof argument.value === "number";
|
|
445
423
|
}
|
|
446
424
|
return false;
|
|
447
425
|
};
|
|
@@ -455,13 +433,12 @@ var isGlobalScope2 = (node) => {
|
|
|
455
433
|
}
|
|
456
434
|
return false;
|
|
457
435
|
};
|
|
458
|
-
var isFunctionOrComponent = (init) => init.type === AST_NODE_TYPES4.ArrowFunctionExpression || init.type === AST_NODE_TYPES4.FunctionExpression;
|
|
459
436
|
var enforceConstantCase = createRule3({
|
|
460
437
|
name: "enforce-constant-case",
|
|
461
438
|
meta: {
|
|
462
439
|
type: "suggestion",
|
|
463
440
|
docs: {
|
|
464
|
-
description: "Enforce SCREAMING_SNAKE_CASE for global
|
|
441
|
+
description: "Enforce SCREAMING_SNAKE_CASE for global magic-number and magic-text constants"
|
|
465
442
|
},
|
|
466
443
|
messages: {
|
|
467
444
|
useScreamingSnakeCase: "Constant '{{ name }}' should use SCREAMING_SNAKE_CASE. Rename to '{{ suggestion }}'.",
|
|
@@ -483,16 +460,10 @@ var enforceConstantCase = createRule3({
|
|
|
483
460
|
if (declarator.id.type !== AST_NODE_TYPES4.Identifier || !declarator.init) {
|
|
484
461
|
return;
|
|
485
462
|
}
|
|
486
|
-
if (
|
|
487
|
-
return;
|
|
488
|
-
}
|
|
489
|
-
if (!isStaticValue2(declarator.init)) {
|
|
463
|
+
if (!isMagicLiteral(declarator.init)) {
|
|
490
464
|
return;
|
|
491
465
|
}
|
|
492
466
|
const { name } = declarator.id;
|
|
493
|
-
if (isBooleanLiteral2(declarator.init) && startsWithBooleanPrefix2(name)) {
|
|
494
|
-
return;
|
|
495
|
-
}
|
|
496
467
|
if (SNAKE_CASE_REGEX2.test(name)) {
|
|
497
468
|
context.report({
|
|
498
469
|
node: declarator.id,
|
|
@@ -515,84 +486,13 @@ var enforceConstantCase = createRule3({
|
|
|
515
486
|
});
|
|
516
487
|
var enforce_constant_case_default = enforceConstantCase;
|
|
517
488
|
|
|
518
|
-
// src/rules/enforce-curly-newline.ts
|
|
519
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES5, ESLintUtils as ESLintUtils4 } from "@typescript-eslint/utils";
|
|
520
|
-
var createRule4 = ESLintUtils4.RuleCreator(
|
|
521
|
-
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
522
|
-
);
|
|
523
|
-
var enforceCurlyNewline = createRule4({
|
|
524
|
-
name: "enforce-curly-newline",
|
|
525
|
-
meta: {
|
|
526
|
-
type: "layout",
|
|
527
|
-
docs: {
|
|
528
|
-
description: "Enforce curly braces for multi-line if statements and forbid them for single-line"
|
|
529
|
-
},
|
|
530
|
-
fixable: "code",
|
|
531
|
-
messages: {
|
|
532
|
-
requireBraces: "Multi-line if statements must use curly braces.",
|
|
533
|
-
forbidBraces: "Single-line if statements must not use curly braces."
|
|
534
|
-
},
|
|
535
|
-
schema: []
|
|
536
|
-
},
|
|
537
|
-
defaultOptions: [],
|
|
538
|
-
create(context) {
|
|
539
|
-
const { sourceCode } = context;
|
|
540
|
-
return {
|
|
541
|
-
IfStatement(node) {
|
|
542
|
-
const { consequent } = node;
|
|
543
|
-
const startLine = node.loc.start.line;
|
|
544
|
-
const endLine = node.loc.end.line;
|
|
545
|
-
const isSingleLine2 = startLine === endLine;
|
|
546
|
-
const hasBraces = consequent.type === AST_NODE_TYPES5.BlockStatement;
|
|
547
|
-
if (isSingleLine2 && hasBraces) {
|
|
548
|
-
if (consequent.body.length !== 1) {
|
|
549
|
-
return;
|
|
550
|
-
}
|
|
551
|
-
const innerStatement = consequent.body[0];
|
|
552
|
-
const innerText = sourceCode.getText(innerStatement);
|
|
553
|
-
context.report({
|
|
554
|
-
node: consequent,
|
|
555
|
-
messageId: "forbidBraces",
|
|
556
|
-
fix(fixer) {
|
|
557
|
-
return fixer.replaceText(consequent, innerText);
|
|
558
|
-
}
|
|
559
|
-
});
|
|
560
|
-
}
|
|
561
|
-
if (!isSingleLine2 && !hasBraces) {
|
|
562
|
-
context.report({
|
|
563
|
-
node: consequent,
|
|
564
|
-
messageId: "requireBraces",
|
|
565
|
-
fix(fixer) {
|
|
566
|
-
const consequentText = sourceCode.getText(consequent);
|
|
567
|
-
const closingParen = sourceCode.getTokenBefore(consequent);
|
|
568
|
-
if (!closingParen) {
|
|
569
|
-
return null;
|
|
570
|
-
}
|
|
571
|
-
const ifStartLine = sourceCode.lines[startLine - 1];
|
|
572
|
-
const indentRegex = /^(\s*)/;
|
|
573
|
-
const indentMatch = indentRegex.exec(ifStartLine);
|
|
574
|
-
const baseIndent = indentMatch ? indentMatch[1] : "";
|
|
575
|
-
const bodyIndent = `${baseIndent} `;
|
|
576
|
-
const newText = ` {
|
|
577
|
-
${bodyIndent}${consequentText.trim()}
|
|
578
|
-
${baseIndent}}`;
|
|
579
|
-
return fixer.replaceTextRange([closingParen.range[1], consequent.range[1]], newText);
|
|
580
|
-
}
|
|
581
|
-
});
|
|
582
|
-
}
|
|
583
|
-
}
|
|
584
|
-
};
|
|
585
|
-
}
|
|
586
|
-
});
|
|
587
|
-
var enforce_curly_newline_default = enforceCurlyNewline;
|
|
588
|
-
|
|
589
489
|
// src/rules/enforce-hook-naming.ts
|
|
590
490
|
import path from "path";
|
|
591
|
-
import { AST_NODE_TYPES as
|
|
592
|
-
var
|
|
491
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES5, ESLintUtils as ESLintUtils4 } from "@typescript-eslint/utils";
|
|
492
|
+
var createRule4 = ESLintUtils4.RuleCreator(
|
|
593
493
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
594
494
|
);
|
|
595
|
-
var enforceHookNaming =
|
|
495
|
+
var enforceHookNaming = createRule4({
|
|
596
496
|
name: "enforce-hook-naming",
|
|
597
497
|
meta: {
|
|
598
498
|
type: "suggestion",
|
|
@@ -631,22 +531,22 @@ var enforceHookNaming = createRule5({
|
|
|
631
531
|
};
|
|
632
532
|
return {
|
|
633
533
|
ExportNamedDeclaration(node) {
|
|
634
|
-
if (node.declaration?.type ===
|
|
534
|
+
if (node.declaration?.type === AST_NODE_TYPES5.FunctionDeclaration && node.declaration.id) {
|
|
635
535
|
checkFunctionName(node.declaration.id.name, node.declaration.id, "missingUsePrefix");
|
|
636
536
|
}
|
|
637
|
-
if (node.declaration?.type ===
|
|
537
|
+
if (node.declaration?.type === AST_NODE_TYPES5.VariableDeclaration) {
|
|
638
538
|
node.declaration.declarations.forEach((declarator) => {
|
|
639
|
-
if (declarator.id.type ===
|
|
539
|
+
if (declarator.id.type === AST_NODE_TYPES5.Identifier) {
|
|
640
540
|
checkFunctionName(declarator.id.name, declarator.id, "missingUsePrefix");
|
|
641
541
|
}
|
|
642
542
|
});
|
|
643
543
|
}
|
|
644
544
|
},
|
|
645
545
|
ExportDefaultDeclaration(node) {
|
|
646
|
-
if (node.declaration.type ===
|
|
546
|
+
if (node.declaration.type === AST_NODE_TYPES5.Identifier) {
|
|
647
547
|
checkFunctionName(node.declaration.name, node.declaration, "defaultExportMissingUsePrefix");
|
|
648
548
|
}
|
|
649
|
-
if (node.declaration.type ===
|
|
549
|
+
if (node.declaration.type === AST_NODE_TYPES5.FunctionDeclaration && node.declaration.id) {
|
|
650
550
|
checkFunctionName(node.declaration.id.name, node.declaration.id, "defaultExportMissingUsePrefix");
|
|
651
551
|
}
|
|
652
552
|
}
|
|
@@ -656,26 +556,26 @@ var enforceHookNaming = createRule5({
|
|
|
656
556
|
var enforce_hook_naming_default = enforceHookNaming;
|
|
657
557
|
|
|
658
558
|
// src/rules/enforce-property-case.ts
|
|
659
|
-
import { AST_NODE_TYPES as
|
|
660
|
-
var
|
|
559
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES6, ESLintUtils as ESLintUtils5 } from "@typescript-eslint/utils";
|
|
560
|
+
var createRule5 = ESLintUtils5.RuleCreator(
|
|
661
561
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
662
562
|
);
|
|
663
563
|
var SNAKE_CASE_REGEX3 = /^[a-z]+_[a-z0-9_]*$/;
|
|
664
564
|
var SCREAMING_SNAKE_CASE_REGEX2 = /^[A-Z][A-Z0-9]*(?:_[A-Z0-9]+)*$/;
|
|
665
565
|
var isInsideAsConst = (node) => {
|
|
666
566
|
const { parent } = node;
|
|
667
|
-
if (parent.type ===
|
|
567
|
+
if (parent.type === AST_NODE_TYPES6.TSAsExpression && parent.typeAnnotation.type === AST_NODE_TYPES6.TSTypeReference && parent.typeAnnotation.typeName.type === AST_NODE_TYPES6.Identifier && parent.typeAnnotation.typeName.name === "const") {
|
|
668
568
|
return true;
|
|
669
569
|
}
|
|
670
|
-
if (parent.type ===
|
|
570
|
+
if (parent.type === AST_NODE_TYPES6.ArrayExpression) {
|
|
671
571
|
const grandparent = parent.parent;
|
|
672
|
-
if (grandparent?.type ===
|
|
572
|
+
if (grandparent?.type === AST_NODE_TYPES6.TSAsExpression && grandparent.typeAnnotation.type === AST_NODE_TYPES6.TSTypeReference && grandparent.typeAnnotation.typeName.type === AST_NODE_TYPES6.Identifier && grandparent.typeAnnotation.typeName.name === "const") {
|
|
673
573
|
return true;
|
|
674
574
|
}
|
|
675
575
|
}
|
|
676
576
|
return false;
|
|
677
577
|
};
|
|
678
|
-
var enforcePropertyCase =
|
|
578
|
+
var enforcePropertyCase = createRule5({
|
|
679
579
|
name: "enforce-property-case",
|
|
680
580
|
meta: {
|
|
681
581
|
type: "suggestion",
|
|
@@ -691,7 +591,7 @@ var enforcePropertyCase = createRule6({
|
|
|
691
591
|
create(context) {
|
|
692
592
|
return {
|
|
693
593
|
Property(node) {
|
|
694
|
-
if (node.parent.type !==
|
|
594
|
+
if (node.parent.type !== AST_NODE_TYPES6.ObjectExpression) {
|
|
695
595
|
return;
|
|
696
596
|
}
|
|
697
597
|
if (isInsideAsConst(node.parent)) {
|
|
@@ -700,7 +600,7 @@ var enforcePropertyCase = createRule6({
|
|
|
700
600
|
if (node.computed) {
|
|
701
601
|
return;
|
|
702
602
|
}
|
|
703
|
-
if (node.key.type !==
|
|
603
|
+
if (node.key.type !== AST_NODE_TYPES6.Identifier) {
|
|
704
604
|
return;
|
|
705
605
|
}
|
|
706
606
|
const { name } = node.key;
|
|
@@ -719,11 +619,11 @@ var enforce_property_case_default = enforcePropertyCase;
|
|
|
719
619
|
|
|
720
620
|
// src/rules/enforce-props-suffix.ts
|
|
721
621
|
import path2 from "path";
|
|
722
|
-
import { AST_NODE_TYPES as
|
|
723
|
-
var
|
|
622
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES7, ESLintUtils as ESLintUtils6 } from "@typescript-eslint/utils";
|
|
623
|
+
var createRule6 = ESLintUtils6.RuleCreator(
|
|
724
624
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
725
625
|
);
|
|
726
|
-
var enforcePropsSuffix =
|
|
626
|
+
var enforcePropsSuffix = createRule6({
|
|
727
627
|
name: "enforce-props-suffix",
|
|
728
628
|
meta: {
|
|
729
629
|
type: "suggestion",
|
|
@@ -757,13 +657,13 @@ var enforcePropsSuffix = createRule7({
|
|
|
757
657
|
};
|
|
758
658
|
return {
|
|
759
659
|
TSInterfaceDeclaration(node) {
|
|
760
|
-
if (node.id.type ===
|
|
660
|
+
if (node.id.type === AST_NODE_TYPES7.Identifier) {
|
|
761
661
|
checkTypeName(node.id.name, node.id);
|
|
762
662
|
}
|
|
763
663
|
},
|
|
764
664
|
TSTypeAliasDeclaration(node) {
|
|
765
|
-
if (node.id.type ===
|
|
766
|
-
if (node.typeAnnotation.type ===
|
|
665
|
+
if (node.id.type === AST_NODE_TYPES7.Identifier) {
|
|
666
|
+
if (node.typeAnnotation.type === AST_NODE_TYPES7.TSTypeLiteral) {
|
|
767
667
|
checkTypeName(node.id.name, node.id);
|
|
768
668
|
}
|
|
769
669
|
}
|
|
@@ -774,11 +674,11 @@ var enforcePropsSuffix = createRule7({
|
|
|
774
674
|
var enforce_props_suffix_default = enforcePropsSuffix;
|
|
775
675
|
|
|
776
676
|
// src/rules/enforce-readonly-component-props.ts
|
|
777
|
-
import { AST_NODE_TYPES as
|
|
778
|
-
var
|
|
677
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES8, ESLintUtils as ESLintUtils7 } from "@typescript-eslint/utils";
|
|
678
|
+
var createRule7 = ESLintUtils7.RuleCreator(
|
|
779
679
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
780
680
|
);
|
|
781
|
-
var enforceReadonlyComponentProps =
|
|
681
|
+
var enforceReadonlyComponentProps = createRule7({
|
|
782
682
|
name: "enforce-readonly-component-props",
|
|
783
683
|
meta: {
|
|
784
684
|
type: "suggestion",
|
|
@@ -794,40 +694,40 @@ var enforceReadonlyComponentProps = createRule8({
|
|
|
794
694
|
defaultOptions: [],
|
|
795
695
|
create(context) {
|
|
796
696
|
function hasJSXInConditional(node) {
|
|
797
|
-
return node.consequent.type ===
|
|
697
|
+
return node.consequent.type === AST_NODE_TYPES8.JSXElement || node.consequent.type === AST_NODE_TYPES8.JSXFragment || node.alternate.type === AST_NODE_TYPES8.JSXElement || node.alternate.type === AST_NODE_TYPES8.JSXFragment;
|
|
798
698
|
}
|
|
799
699
|
function hasJSXInLogical(node) {
|
|
800
|
-
return node.right.type ===
|
|
700
|
+
return node.right.type === AST_NODE_TYPES8.JSXElement || node.right.type === AST_NODE_TYPES8.JSXFragment;
|
|
801
701
|
}
|
|
802
702
|
function hasJSXReturn(block) {
|
|
803
703
|
return block.body.some((stmt) => {
|
|
804
|
-
if (stmt.type ===
|
|
805
|
-
return stmt.argument.type ===
|
|
704
|
+
if (stmt.type === AST_NODE_TYPES8.ReturnStatement && stmt.argument) {
|
|
705
|
+
return stmt.argument.type === AST_NODE_TYPES8.JSXElement || stmt.argument.type === AST_NODE_TYPES8.JSXFragment || stmt.argument.type === AST_NODE_TYPES8.ConditionalExpression && hasJSXInConditional(stmt.argument) || stmt.argument.type === AST_NODE_TYPES8.LogicalExpression && hasJSXInLogical(stmt.argument);
|
|
806
706
|
}
|
|
807
707
|
return false;
|
|
808
708
|
});
|
|
809
709
|
}
|
|
810
710
|
function isReactComponent2(node) {
|
|
811
|
-
if (node.type ===
|
|
812
|
-
if (node.body.type ===
|
|
711
|
+
if (node.type === AST_NODE_TYPES8.ArrowFunctionExpression) {
|
|
712
|
+
if (node.body.type === AST_NODE_TYPES8.JSXElement || node.body.type === AST_NODE_TYPES8.JSXFragment) {
|
|
813
713
|
return true;
|
|
814
714
|
}
|
|
815
|
-
if (node.body.type ===
|
|
715
|
+
if (node.body.type === AST_NODE_TYPES8.BlockStatement) {
|
|
816
716
|
return hasJSXReturn(node.body);
|
|
817
717
|
}
|
|
818
|
-
} else if (node.type ===
|
|
819
|
-
if (node.body && node.body.type ===
|
|
718
|
+
} else if (node.type === AST_NODE_TYPES8.FunctionExpression || node.type === AST_NODE_TYPES8.FunctionDeclaration) {
|
|
719
|
+
if (node.body && node.body.type === AST_NODE_TYPES8.BlockStatement) {
|
|
820
720
|
return hasJSXReturn(node.body);
|
|
821
721
|
}
|
|
822
722
|
}
|
|
823
723
|
return false;
|
|
824
724
|
}
|
|
825
725
|
function isNamedType(node) {
|
|
826
|
-
return node.type ===
|
|
726
|
+
return node.type === AST_NODE_TYPES8.TSTypeReference;
|
|
827
727
|
}
|
|
828
728
|
function isAlreadyReadonly(node) {
|
|
829
|
-
if (node.type ===
|
|
830
|
-
if (node.typeName.type ===
|
|
729
|
+
if (node.type === AST_NODE_TYPES8.TSTypeReference && node.typeName) {
|
|
730
|
+
if (node.typeName.type === AST_NODE_TYPES8.Identifier && node.typeName.name === "Readonly") {
|
|
831
731
|
return true;
|
|
832
732
|
}
|
|
833
733
|
}
|
|
@@ -841,7 +741,7 @@ var enforceReadonlyComponentProps = createRule8({
|
|
|
841
741
|
return;
|
|
842
742
|
}
|
|
843
743
|
const param = node.params[0];
|
|
844
|
-
if (param.type ===
|
|
744
|
+
if (param.type === AST_NODE_TYPES8.Identifier && param.typeAnnotation) {
|
|
845
745
|
const { typeAnnotation } = param.typeAnnotation;
|
|
846
746
|
if (isNamedType(typeAnnotation) && !isAlreadyReadonly(typeAnnotation)) {
|
|
847
747
|
const { sourceCode } = context;
|
|
@@ -866,8 +766,8 @@ var enforceReadonlyComponentProps = createRule8({
|
|
|
866
766
|
var enforce_readonly_component_props_default = enforceReadonlyComponentProps;
|
|
867
767
|
|
|
868
768
|
// src/rules/enforce-service-naming.ts
|
|
869
|
-
import { AST_NODE_TYPES as
|
|
870
|
-
var
|
|
769
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES9, ESLintUtils as ESLintUtils8 } from "@typescript-eslint/utils";
|
|
770
|
+
var createRule8 = ESLintUtils8.RuleCreator(
|
|
871
771
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
872
772
|
);
|
|
873
773
|
var BANNED_PREFIXES = {
|
|
@@ -876,7 +776,7 @@ var BANNED_PREFIXES = {
|
|
|
876
776
|
handle: ["create", "verify"],
|
|
877
777
|
set: ["update", "save", "patch"]
|
|
878
778
|
};
|
|
879
|
-
var enforceServiceNaming =
|
|
779
|
+
var enforceServiceNaming = createRule8({
|
|
880
780
|
name: "enforce-service-naming",
|
|
881
781
|
meta: {
|
|
882
782
|
type: "suggestion",
|
|
@@ -919,12 +819,12 @@ var enforceServiceNaming = createRule9({
|
|
|
919
819
|
};
|
|
920
820
|
return {
|
|
921
821
|
ExportNamedDeclaration(node) {
|
|
922
|
-
if (node.declaration?.type ===
|
|
822
|
+
if (node.declaration?.type === AST_NODE_TYPES9.FunctionDeclaration && node.declaration.id) {
|
|
923
823
|
checkExportedFunction(node.declaration, node.declaration.id);
|
|
924
824
|
}
|
|
925
|
-
if (node.declaration?.type ===
|
|
825
|
+
if (node.declaration?.type === AST_NODE_TYPES9.VariableDeclaration) {
|
|
926
826
|
node.declaration.declarations.forEach((declarator) => {
|
|
927
|
-
if (declarator.id.type ===
|
|
827
|
+
if (declarator.id.type === AST_NODE_TYPES9.Identifier && declarator.init?.type === AST_NODE_TYPES9.ArrowFunctionExpression) {
|
|
928
828
|
checkExportedFunction(declarator.init, declarator.id);
|
|
929
829
|
}
|
|
930
830
|
});
|
|
@@ -936,11 +836,11 @@ var enforceServiceNaming = createRule9({
|
|
|
936
836
|
var enforce_service_naming_default = enforceServiceNaming;
|
|
937
837
|
|
|
938
838
|
// src/rules/enforce-sorted-destructuring.ts
|
|
939
|
-
import { AST_NODE_TYPES as
|
|
940
|
-
var
|
|
839
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES10, ESLintUtils as ESLintUtils9 } from "@typescript-eslint/utils";
|
|
840
|
+
var createRule9 = ESLintUtils9.RuleCreator(
|
|
941
841
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
942
842
|
);
|
|
943
|
-
var enforceSortedDestructuring =
|
|
843
|
+
var enforceSortedDestructuring = createRule9({
|
|
944
844
|
name: "enforce-sorted-destructuring",
|
|
945
845
|
meta: {
|
|
946
846
|
type: "suggestion",
|
|
@@ -956,19 +856,19 @@ var enforceSortedDestructuring = createRule10({
|
|
|
956
856
|
defaultOptions: [],
|
|
957
857
|
create(context) {
|
|
958
858
|
function getPropertyName(property) {
|
|
959
|
-
if (property.type ===
|
|
859
|
+
if (property.type === AST_NODE_TYPES10.RestElement) {
|
|
960
860
|
return null;
|
|
961
861
|
}
|
|
962
|
-
if (property.key.type ===
|
|
862
|
+
if (property.key.type === AST_NODE_TYPES10.Identifier) {
|
|
963
863
|
return property.key.name;
|
|
964
864
|
}
|
|
965
865
|
return null;
|
|
966
866
|
}
|
|
967
867
|
function hasDefaultValue(property) {
|
|
968
|
-
return property.value.type ===
|
|
868
|
+
return property.value.type === AST_NODE_TYPES10.AssignmentPattern && Boolean(property.value.right);
|
|
969
869
|
}
|
|
970
870
|
function checkVariableDeclarator(node) {
|
|
971
|
-
if (node.id.type !==
|
|
871
|
+
if (node.id.type !== AST_NODE_TYPES10.ObjectPattern) {
|
|
972
872
|
return;
|
|
973
873
|
}
|
|
974
874
|
const { properties } = node.id;
|
|
@@ -976,7 +876,7 @@ var enforceSortedDestructuring = createRule10({
|
|
|
976
876
|
return;
|
|
977
877
|
}
|
|
978
878
|
const propertyInfo = properties.map((prop) => {
|
|
979
|
-
if (prop.type ===
|
|
879
|
+
if (prop.type === AST_NODE_TYPES10.RestElement) {
|
|
980
880
|
return null;
|
|
981
881
|
}
|
|
982
882
|
return {
|
|
@@ -1015,20 +915,20 @@ var enforceSortedDestructuring = createRule10({
|
|
|
1015
915
|
var enforce_sorted_destructuring_default = enforceSortedDestructuring;
|
|
1016
916
|
|
|
1017
917
|
// src/rules/enforce-type-declaration-order.ts
|
|
1018
|
-
import { AST_NODE_TYPES as
|
|
1019
|
-
var
|
|
918
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES11, ESLintUtils as ESLintUtils10 } from "@typescript-eslint/utils";
|
|
919
|
+
var createRule10 = ESLintUtils10.RuleCreator(
|
|
1020
920
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1021
921
|
);
|
|
1022
922
|
function getTypeDeclarationName(node) {
|
|
1023
|
-
if (node.type ===
|
|
923
|
+
if (node.type === AST_NODE_TYPES11.TSInterfaceDeclaration && node.id.type === AST_NODE_TYPES11.Identifier) {
|
|
1024
924
|
return { name: node.id.name, position: node.range[0] };
|
|
1025
925
|
}
|
|
1026
|
-
if (node.type ===
|
|
926
|
+
if (node.type === AST_NODE_TYPES11.TSTypeAliasDeclaration && node.id.type === AST_NODE_TYPES11.Identifier) {
|
|
1027
927
|
return { name: node.id.name, position: node.range[0] };
|
|
1028
928
|
}
|
|
1029
929
|
return null;
|
|
1030
930
|
}
|
|
1031
|
-
var enforceTypeDeclarationOrder =
|
|
931
|
+
var enforceTypeDeclarationOrder = createRule10({
|
|
1032
932
|
name: "enforce-type-declaration-order",
|
|
1033
933
|
meta: {
|
|
1034
934
|
type: "suggestion",
|
|
@@ -1059,7 +959,7 @@ var enforceTypeDeclarationOrder = createRule11({
|
|
|
1059
959
|
}
|
|
1060
960
|
},
|
|
1061
961
|
"TSPropertySignature TSTypeReference": function checkTypeReference(node) {
|
|
1062
|
-
if (node.typeName.type !==
|
|
962
|
+
if (node.typeName.type !== AST_NODE_TYPES11.Identifier) {
|
|
1063
963
|
return;
|
|
1064
964
|
}
|
|
1065
965
|
const referencedName = node.typeName.name;
|
|
@@ -1095,55 +995,9 @@ var enforceTypeDeclarationOrder = createRule11({
|
|
|
1095
995
|
});
|
|
1096
996
|
var enforce_type_declaration_order_default = enforceTypeDeclarationOrder;
|
|
1097
997
|
|
|
1098
|
-
// src/rules/file-kebab-case.ts
|
|
1099
|
-
import path3 from "path";
|
|
1100
|
-
import { ESLintUtils as ESLintUtils12 } from "@typescript-eslint/utils";
|
|
1101
|
-
var createRule12 = ESLintUtils12.RuleCreator(
|
|
1102
|
-
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1103
|
-
);
|
|
1104
|
-
var isKebabCase = (str) => {
|
|
1105
|
-
if (/\.(config|rc|setup|spec|test)$/.test(str) || /^[a-z0-9]+(?:-[a-z0-9]+)*\.[a-z0-9]+(?:-[a-z0-9]+)*$/.test(str)) {
|
|
1106
|
-
return /^[a-z0-9]+(?:-[a-z0-9]+)*(?:\.[a-z0-9]+(?:-[a-z0-9]+)*)*$/.test(str);
|
|
1107
|
-
}
|
|
1108
|
-
return /^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(str);
|
|
1109
|
-
};
|
|
1110
|
-
var fileKebabCase = createRule12({
|
|
1111
|
-
name: "file-kebab-case",
|
|
1112
|
-
meta: {
|
|
1113
|
-
type: "problem",
|
|
1114
|
-
docs: {
|
|
1115
|
-
description: "Enforce kebab-case filenames for .ts and .js files"
|
|
1116
|
-
},
|
|
1117
|
-
messages: {
|
|
1118
|
-
fileKebabCase: "File names must be kebab-case"
|
|
1119
|
-
},
|
|
1120
|
-
schema: []
|
|
1121
|
-
},
|
|
1122
|
-
defaultOptions: [],
|
|
1123
|
-
create(context) {
|
|
1124
|
-
return {
|
|
1125
|
-
Program() {
|
|
1126
|
-
const { filename } = context;
|
|
1127
|
-
const ext = path3.extname(filename);
|
|
1128
|
-
if (ext !== ".ts" && ext !== ".js") {
|
|
1129
|
-
return;
|
|
1130
|
-
}
|
|
1131
|
-
const basename2 = path3.basename(filename, ext);
|
|
1132
|
-
if (!isKebabCase(basename2)) {
|
|
1133
|
-
context.report({
|
|
1134
|
-
loc: { line: 1, column: 0 },
|
|
1135
|
-
messageId: "fileKebabCase"
|
|
1136
|
-
});
|
|
1137
|
-
}
|
|
1138
|
-
}
|
|
1139
|
-
};
|
|
1140
|
-
}
|
|
1141
|
-
});
|
|
1142
|
-
var file_kebab_case_default = fileKebabCase;
|
|
1143
|
-
|
|
1144
998
|
// src/rules/index-export-only.ts
|
|
1145
|
-
import { AST_NODE_TYPES as
|
|
1146
|
-
var
|
|
999
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES12, ESLintUtils as ESLintUtils11 } from "@typescript-eslint/utils";
|
|
1000
|
+
var createRule11 = ESLintUtils11.RuleCreator(
|
|
1147
1001
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1148
1002
|
);
|
|
1149
1003
|
var isIndexFile = (filename) => getBaseName(filename) === "index";
|
|
@@ -1151,26 +1005,26 @@ var isAllowedExportNamed = (node) => {
|
|
|
1151
1005
|
if (!node.declaration) {
|
|
1152
1006
|
return true;
|
|
1153
1007
|
}
|
|
1154
|
-
return node.declaration.type ===
|
|
1008
|
+
return node.declaration.type === AST_NODE_TYPES12.TSTypeAliasDeclaration || node.declaration.type === AST_NODE_TYPES12.TSInterfaceDeclaration;
|
|
1155
1009
|
};
|
|
1156
|
-
var isAllowedExportDefault = (node) => node.declaration.type ===
|
|
1010
|
+
var isAllowedExportDefault = (node) => node.declaration.type === AST_NODE_TYPES12.Identifier;
|
|
1157
1011
|
var isAllowedTopLevel = (node) => {
|
|
1158
1012
|
switch (node.type) {
|
|
1159
|
-
case
|
|
1160
|
-
case
|
|
1161
|
-
case
|
|
1162
|
-
case
|
|
1163
|
-
case
|
|
1013
|
+
case AST_NODE_TYPES12.ImportDeclaration:
|
|
1014
|
+
case AST_NODE_TYPES12.ExportAllDeclaration:
|
|
1015
|
+
case AST_NODE_TYPES12.TSTypeAliasDeclaration:
|
|
1016
|
+
case AST_NODE_TYPES12.TSInterfaceDeclaration:
|
|
1017
|
+
case AST_NODE_TYPES12.TSImportEqualsDeclaration:
|
|
1164
1018
|
return true;
|
|
1165
|
-
case
|
|
1019
|
+
case AST_NODE_TYPES12.ExportNamedDeclaration:
|
|
1166
1020
|
return isAllowedExportNamed(node);
|
|
1167
|
-
case
|
|
1021
|
+
case AST_NODE_TYPES12.ExportDefaultDeclaration:
|
|
1168
1022
|
return isAllowedExportDefault(node);
|
|
1169
1023
|
default:
|
|
1170
1024
|
return false;
|
|
1171
1025
|
}
|
|
1172
1026
|
};
|
|
1173
|
-
var indexExportOnly =
|
|
1027
|
+
var indexExportOnly = createRule11({
|
|
1174
1028
|
name: "index-export-only",
|
|
1175
1029
|
meta: {
|
|
1176
1030
|
type: "suggestion",
|
|
@@ -1204,11 +1058,11 @@ var indexExportOnly = createRule13({
|
|
|
1204
1058
|
var index_export_only_default = indexExportOnly;
|
|
1205
1059
|
|
|
1206
1060
|
// src/rules/jsx-newline-between-elements.ts
|
|
1207
|
-
import { AST_NODE_TYPES as
|
|
1208
|
-
var
|
|
1061
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES13, ESLintUtils as ESLintUtils12 } from "@typescript-eslint/utils";
|
|
1062
|
+
var createRule12 = ESLintUtils12.RuleCreator(
|
|
1209
1063
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1210
1064
|
);
|
|
1211
|
-
var jsxNewlineBetweenElements =
|
|
1065
|
+
var jsxNewlineBetweenElements = createRule12({
|
|
1212
1066
|
name: "jsx-newline-between-elements",
|
|
1213
1067
|
meta: {
|
|
1214
1068
|
type: "layout",
|
|
@@ -1226,7 +1080,7 @@ var jsxNewlineBetweenElements = createRule14({
|
|
|
1226
1080
|
create(context) {
|
|
1227
1081
|
const { sourceCode } = context;
|
|
1228
1082
|
function isSignificantJSXChild(node) {
|
|
1229
|
-
return node.type ===
|
|
1083
|
+
return node.type === AST_NODE_TYPES13.JSXElement || node.type === AST_NODE_TYPES13.JSXFragment || node.type === AST_NODE_TYPES13.JSXExpressionContainer;
|
|
1230
1084
|
}
|
|
1231
1085
|
function isMultiLine(node) {
|
|
1232
1086
|
return node.loc.start.line !== node.loc.end.line;
|
|
@@ -1276,11 +1130,11 @@ var jsxNewlineBetweenElements = createRule14({
|
|
|
1276
1130
|
var jsx_newline_between_elements_default = jsxNewlineBetweenElements;
|
|
1277
1131
|
|
|
1278
1132
|
// src/rules/jsx-no-inline-object-prop.ts
|
|
1279
|
-
import { AST_NODE_TYPES as
|
|
1280
|
-
var
|
|
1133
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES14, ESLintUtils as ESLintUtils13 } from "@typescript-eslint/utils";
|
|
1134
|
+
var createRule13 = ESLintUtils13.RuleCreator(
|
|
1281
1135
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1282
1136
|
);
|
|
1283
|
-
var jsxNoInlineObjectProp =
|
|
1137
|
+
var jsxNoInlineObjectProp = createRule13({
|
|
1284
1138
|
name: "jsx-no-inline-object-prop",
|
|
1285
1139
|
meta: {
|
|
1286
1140
|
type: "suggestion",
|
|
@@ -1296,7 +1150,7 @@ var jsxNoInlineObjectProp = createRule15({
|
|
|
1296
1150
|
create(context) {
|
|
1297
1151
|
return {
|
|
1298
1152
|
JSXAttribute(node) {
|
|
1299
|
-
if (node.value?.type ===
|
|
1153
|
+
if (node.value?.type === AST_NODE_TYPES14.JSXExpressionContainer && node.value.expression.type === AST_NODE_TYPES14.ObjectExpression) {
|
|
1300
1154
|
context.report({
|
|
1301
1155
|
node: node.value,
|
|
1302
1156
|
messageId: "noInlineObject"
|
|
@@ -1309,17 +1163,17 @@ var jsxNoInlineObjectProp = createRule15({
|
|
|
1309
1163
|
var jsx_no_inline_object_prop_default = jsxNoInlineObjectProp;
|
|
1310
1164
|
|
|
1311
1165
|
// src/rules/jsx-no-newline-single-line-elements.ts
|
|
1312
|
-
import { AST_NODE_TYPES as
|
|
1313
|
-
var
|
|
1166
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES15, ESLintUtils as ESLintUtils14 } from "@typescript-eslint/utils";
|
|
1167
|
+
var createRule14 = ESLintUtils14.RuleCreator(
|
|
1314
1168
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1315
1169
|
);
|
|
1316
1170
|
function isJSXElementOrFragment(node) {
|
|
1317
|
-
return node.type ===
|
|
1171
|
+
return node.type === AST_NODE_TYPES15.JSXElement || node.type === AST_NODE_TYPES15.JSXFragment;
|
|
1318
1172
|
}
|
|
1319
1173
|
function isSingleLine(node) {
|
|
1320
1174
|
return node.loc.start.line === node.loc.end.line;
|
|
1321
1175
|
}
|
|
1322
|
-
var jsxNoNewlineSingleLineElements =
|
|
1176
|
+
var jsxNoNewlineSingleLineElements = createRule14({
|
|
1323
1177
|
name: "jsx-no-newline-single-line-elements",
|
|
1324
1178
|
meta: {
|
|
1325
1179
|
type: "layout",
|
|
@@ -1337,7 +1191,7 @@ var jsxNoNewlineSingleLineElements = createRule16({
|
|
|
1337
1191
|
const { sourceCode } = context;
|
|
1338
1192
|
function checkSiblings(children) {
|
|
1339
1193
|
const nonWhitespace = children.filter(
|
|
1340
|
-
(child) => !(child.type ===
|
|
1194
|
+
(child) => !(child.type === AST_NODE_TYPES15.JSXText && child.value.trim() === "")
|
|
1341
1195
|
);
|
|
1342
1196
|
nonWhitespace.forEach((next, index) => {
|
|
1343
1197
|
if (index === 0) {
|
|
@@ -1388,11 +1242,11 @@ ${indent}`);
|
|
|
1388
1242
|
var jsx_no_newline_single_line_elements_default = jsxNoNewlineSingleLineElements;
|
|
1389
1243
|
|
|
1390
1244
|
// src/rules/jsx-no-non-component-function.ts
|
|
1391
|
-
import { AST_NODE_TYPES as
|
|
1392
|
-
var
|
|
1245
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES16, ESLintUtils as ESLintUtils15 } from "@typescript-eslint/utils";
|
|
1246
|
+
var createRule15 = ESLintUtils15.RuleCreator(
|
|
1393
1247
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1394
1248
|
);
|
|
1395
|
-
var jsxNoNonComponentFunction =
|
|
1249
|
+
var jsxNoNonComponentFunction = createRule15({
|
|
1396
1250
|
name: "jsx-no-non-component-function",
|
|
1397
1251
|
meta: {
|
|
1398
1252
|
type: "problem",
|
|
@@ -1412,13 +1266,13 @@ var jsxNoNonComponentFunction = createRule17({
|
|
|
1412
1266
|
return {};
|
|
1413
1267
|
}
|
|
1414
1268
|
function isReactComponent2(node) {
|
|
1415
|
-
const functionName = node.type ===
|
|
1269
|
+
const functionName = node.type === AST_NODE_TYPES16.FunctionDeclaration && node.id ? node.id.name : null;
|
|
1416
1270
|
if (functionName && /^[A-Z]/.test(functionName)) {
|
|
1417
1271
|
return true;
|
|
1418
1272
|
}
|
|
1419
1273
|
if (node.returnType?.typeAnnotation) {
|
|
1420
1274
|
const returnTypeNode = node.returnType.typeAnnotation;
|
|
1421
|
-
if (returnTypeNode.type ===
|
|
1275
|
+
if (returnTypeNode.type === AST_NODE_TYPES16.TSTypeReference && returnTypeNode.typeName.type === AST_NODE_TYPES16.Identifier) {
|
|
1422
1276
|
const typeName = returnTypeNode.typeName.name;
|
|
1423
1277
|
if (typeName === "JSX" || typeName === "ReactElement" || typeName === "ReactNode") {
|
|
1424
1278
|
return true;
|
|
@@ -1435,13 +1289,13 @@ var jsxNoNonComponentFunction = createRule17({
|
|
|
1435
1289
|
if (!parent) {
|
|
1436
1290
|
return;
|
|
1437
1291
|
}
|
|
1438
|
-
if (parent.type ===
|
|
1292
|
+
if (parent.type === AST_NODE_TYPES16.ExportDefaultDeclaration || parent.type === AST_NODE_TYPES16.ExportNamedDeclaration) {
|
|
1439
1293
|
return;
|
|
1440
1294
|
}
|
|
1441
|
-
if (declaratorNode?.parent?.parent?.type ===
|
|
1295
|
+
if (declaratorNode?.parent?.parent?.type === AST_NODE_TYPES16.ExportNamedDeclaration) {
|
|
1442
1296
|
return;
|
|
1443
1297
|
}
|
|
1444
|
-
if (declaratorNode?.id.type ===
|
|
1298
|
+
if (declaratorNode?.id.type === AST_NODE_TYPES16.Identifier) {
|
|
1445
1299
|
const varName = declaratorNode.id.name;
|
|
1446
1300
|
if (/^[A-Z]/.test(varName)) {
|
|
1447
1301
|
return;
|
|
@@ -1466,20 +1320,20 @@ var jsxNoNonComponentFunction = createRule17({
|
|
|
1466
1320
|
var jsx_no_non_component_function_default = jsxNoNonComponentFunction;
|
|
1467
1321
|
|
|
1468
1322
|
// src/rules/jsx-no-ternary-null.ts
|
|
1469
|
-
import { AST_NODE_TYPES as
|
|
1470
|
-
var
|
|
1323
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES17, ESLintUtils as ESLintUtils16 } from "@typescript-eslint/utils";
|
|
1324
|
+
var createRule16 = ESLintUtils16.RuleCreator(
|
|
1471
1325
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1472
1326
|
);
|
|
1473
1327
|
function isNullOrUndefined(node) {
|
|
1474
|
-
if (node.type ===
|
|
1328
|
+
if (node.type === AST_NODE_TYPES17.Literal && node.value === null) {
|
|
1475
1329
|
return true;
|
|
1476
1330
|
}
|
|
1477
|
-
if (node.type ===
|
|
1331
|
+
if (node.type === AST_NODE_TYPES17.Identifier && node.name === "undefined") {
|
|
1478
1332
|
return true;
|
|
1479
1333
|
}
|
|
1480
1334
|
return false;
|
|
1481
1335
|
}
|
|
1482
|
-
var jsxNoTernaryNull =
|
|
1336
|
+
var jsxNoTernaryNull = createRule16({
|
|
1483
1337
|
name: "jsx-no-ternary-null",
|
|
1484
1338
|
meta: {
|
|
1485
1339
|
type: "suggestion",
|
|
@@ -1497,7 +1351,7 @@ var jsxNoTernaryNull = createRule18({
|
|
|
1497
1351
|
return {
|
|
1498
1352
|
JSXExpressionContainer(node) {
|
|
1499
1353
|
const { expression } = node;
|
|
1500
|
-
if (expression.type !==
|
|
1354
|
+
if (expression.type !== AST_NODE_TYPES17.ConditionalExpression) {
|
|
1501
1355
|
return;
|
|
1502
1356
|
}
|
|
1503
1357
|
const { test, consequent, alternate } = expression;
|
|
@@ -1529,11 +1383,11 @@ var jsxNoTernaryNull = createRule18({
|
|
|
1529
1383
|
var jsx_no_ternary_null_default = jsxNoTernaryNull;
|
|
1530
1384
|
|
|
1531
1385
|
// src/rules/jsx-no-variable-in-callback.ts
|
|
1532
|
-
import { AST_NODE_TYPES as
|
|
1533
|
-
var
|
|
1386
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES18, ESLintUtils as ESLintUtils17 } from "@typescript-eslint/utils";
|
|
1387
|
+
var createRule17 = ESLintUtils17.RuleCreator(
|
|
1534
1388
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1535
1389
|
);
|
|
1536
|
-
var jsxNoVariableInCallback =
|
|
1390
|
+
var jsxNoVariableInCallback = createRule17({
|
|
1537
1391
|
name: "jsx-no-variable-in-callback",
|
|
1538
1392
|
meta: {
|
|
1539
1393
|
type: "suggestion",
|
|
@@ -1550,7 +1404,7 @@ var jsxNoVariableInCallback = createRule19({
|
|
|
1550
1404
|
function isInsideJSX(node) {
|
|
1551
1405
|
let current = node.parent;
|
|
1552
1406
|
while (current) {
|
|
1553
|
-
if (current.type ===
|
|
1407
|
+
if (current.type === AST_NODE_TYPES18.JSXElement || current.type === AST_NODE_TYPES18.JSXFragment) {
|
|
1554
1408
|
return true;
|
|
1555
1409
|
}
|
|
1556
1410
|
current = current.parent;
|
|
@@ -1564,11 +1418,11 @@ var jsxNoVariableInCallback = createRule19({
|
|
|
1564
1418
|
if (!isInsideJSX(node)) {
|
|
1565
1419
|
return false;
|
|
1566
1420
|
}
|
|
1567
|
-
if (node.parent.type ===
|
|
1421
|
+
if (node.parent.type === AST_NODE_TYPES18.CallExpression || node.parent.type === AST_NODE_TYPES18.JSXExpressionContainer) {
|
|
1568
1422
|
return true;
|
|
1569
1423
|
}
|
|
1570
|
-
if (node.parent.type ===
|
|
1571
|
-
if (node.parent.parent.type ===
|
|
1424
|
+
if (node.parent.type === AST_NODE_TYPES18.ArrayExpression && node.parent.parent) {
|
|
1425
|
+
if (node.parent.parent.type === AST_NODE_TYPES18.CallExpression || node.parent.parent.type === AST_NODE_TYPES18.JSXExpressionContainer) {
|
|
1572
1426
|
return true;
|
|
1573
1427
|
}
|
|
1574
1428
|
}
|
|
@@ -1579,11 +1433,11 @@ var jsxNoVariableInCallback = createRule19({
|
|
|
1579
1433
|
return;
|
|
1580
1434
|
}
|
|
1581
1435
|
const { body } = node;
|
|
1582
|
-
if (body.type !==
|
|
1436
|
+
if (body.type !== AST_NODE_TYPES18.BlockStatement) {
|
|
1583
1437
|
return;
|
|
1584
1438
|
}
|
|
1585
1439
|
body.body.forEach((statement) => {
|
|
1586
|
-
if (statement.type ===
|
|
1440
|
+
if (statement.type === AST_NODE_TYPES18.VariableDeclaration) {
|
|
1587
1441
|
context.report({
|
|
1588
1442
|
node: statement,
|
|
1589
1443
|
messageId: "noVariableInCallback"
|
|
@@ -1599,53 +1453,12 @@ var jsxNoVariableInCallback = createRule19({
|
|
|
1599
1453
|
});
|
|
1600
1454
|
var jsx_no_variable_in_callback_default = jsxNoVariableInCallback;
|
|
1601
1455
|
|
|
1602
|
-
// src/rules/jsx-pascal-case.ts
|
|
1603
|
-
import path4 from "path";
|
|
1604
|
-
import { ESLintUtils as ESLintUtils20 } from "@typescript-eslint/utils";
|
|
1605
|
-
var createRule20 = ESLintUtils20.RuleCreator(
|
|
1606
|
-
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1607
|
-
);
|
|
1608
|
-
var isPascalCase = (str) => /^[A-Z][a-zA-Z0-9]*$/.test(str) && !/^[A-Z]+$/.test(str);
|
|
1609
|
-
var jsxPascalCase = createRule20({
|
|
1610
|
-
name: "jsx-pascal-case",
|
|
1611
|
-
meta: {
|
|
1612
|
-
type: "problem",
|
|
1613
|
-
docs: {
|
|
1614
|
-
description: "Enforce PascalCase filenames for .jsx and .tsx files"
|
|
1615
|
-
},
|
|
1616
|
-
messages: {
|
|
1617
|
-
jsxPascalCase: "JSX/TSX file names must be PascalCase"
|
|
1618
|
-
},
|
|
1619
|
-
schema: []
|
|
1620
|
-
},
|
|
1621
|
-
defaultOptions: [],
|
|
1622
|
-
create(context) {
|
|
1623
|
-
return {
|
|
1624
|
-
Program() {
|
|
1625
|
-
const { filename } = context;
|
|
1626
|
-
const ext = path4.extname(filename);
|
|
1627
|
-
if (ext !== ".jsx" && ext !== ".tsx") {
|
|
1628
|
-
return;
|
|
1629
|
-
}
|
|
1630
|
-
const basename2 = path4.basename(filename, ext);
|
|
1631
|
-
if (!isPascalCase(basename2)) {
|
|
1632
|
-
context.report({
|
|
1633
|
-
loc: { line: 1, column: 0 },
|
|
1634
|
-
messageId: "jsxPascalCase"
|
|
1635
|
-
});
|
|
1636
|
-
}
|
|
1637
|
-
}
|
|
1638
|
-
};
|
|
1639
|
-
}
|
|
1640
|
-
});
|
|
1641
|
-
var jsx_pascal_case_default = jsxPascalCase;
|
|
1642
|
-
|
|
1643
1456
|
// src/rules/jsx-require-suspense.ts
|
|
1644
|
-
import { AST_NODE_TYPES as
|
|
1645
|
-
var
|
|
1457
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES19, ESLintUtils as ESLintUtils18 } from "@typescript-eslint/utils";
|
|
1458
|
+
var createRule18 = ESLintUtils18.RuleCreator(
|
|
1646
1459
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1647
1460
|
);
|
|
1648
|
-
var jsxRequireSuspense =
|
|
1461
|
+
var jsxRequireSuspense = createRule18({
|
|
1649
1462
|
name: "jsx-require-suspense",
|
|
1650
1463
|
meta: {
|
|
1651
1464
|
type: "problem",
|
|
@@ -1663,7 +1476,7 @@ var jsxRequireSuspense = createRule21({
|
|
|
1663
1476
|
const isInsideSuspense = (node) => {
|
|
1664
1477
|
let current = node.parent;
|
|
1665
1478
|
while (current) {
|
|
1666
|
-
if (current.type ===
|
|
1479
|
+
if (current.type === AST_NODE_TYPES19.JSXElement && current.openingElement.name.type === AST_NODE_TYPES19.JSXIdentifier && current.openingElement.name.name === "Suspense") {
|
|
1667
1480
|
return true;
|
|
1668
1481
|
}
|
|
1669
1482
|
current = current.parent;
|
|
@@ -1672,16 +1485,16 @@ var jsxRequireSuspense = createRule21({
|
|
|
1672
1485
|
};
|
|
1673
1486
|
return {
|
|
1674
1487
|
VariableDeclarator(node) {
|
|
1675
|
-
if (node.id.type ===
|
|
1488
|
+
if (node.id.type === AST_NODE_TYPES19.Identifier && node.init?.type === AST_NODE_TYPES19.CallExpression) {
|
|
1676
1489
|
const { callee } = node.init;
|
|
1677
|
-
const isLazyCall = callee.type ===
|
|
1490
|
+
const isLazyCall = callee.type === AST_NODE_TYPES19.Identifier && callee.name === "lazy" || callee.type === AST_NODE_TYPES19.MemberExpression && callee.object.type === AST_NODE_TYPES19.Identifier && callee.object.name === "React" && callee.property.type === AST_NODE_TYPES19.Identifier && callee.property.name === "lazy";
|
|
1678
1491
|
if (isLazyCall) {
|
|
1679
1492
|
lazyComponents.add(node.id.name);
|
|
1680
1493
|
}
|
|
1681
1494
|
}
|
|
1682
1495
|
},
|
|
1683
1496
|
JSXOpeningElement(node) {
|
|
1684
|
-
if (node.name.type ===
|
|
1497
|
+
if (node.name.type === AST_NODE_TYPES19.JSXIdentifier) {
|
|
1685
1498
|
const componentName = node.name.name;
|
|
1686
1499
|
if (lazyComponents.has(componentName) && !isInsideSuspense(node)) {
|
|
1687
1500
|
context.report({
|
|
@@ -1700,11 +1513,11 @@ var jsxRequireSuspense = createRule21({
|
|
|
1700
1513
|
var jsx_require_suspense_default = jsxRequireSuspense;
|
|
1701
1514
|
|
|
1702
1515
|
// src/rules/jsx-simple-props.ts
|
|
1703
|
-
import { AST_NODE_TYPES as
|
|
1704
|
-
var
|
|
1516
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES20, ESLintUtils as ESLintUtils19 } from "@typescript-eslint/utils";
|
|
1517
|
+
var createRule19 = ESLintUtils19.RuleCreator(
|
|
1705
1518
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1706
1519
|
);
|
|
1707
|
-
var jsxSimpleProps =
|
|
1520
|
+
var jsxSimpleProps = createRule19({
|
|
1708
1521
|
name: "jsx-simple-props",
|
|
1709
1522
|
meta: {
|
|
1710
1523
|
type: "suggestion",
|
|
@@ -1719,25 +1532,25 @@ var jsxSimpleProps = createRule22({
|
|
|
1719
1532
|
defaultOptions: [],
|
|
1720
1533
|
create(context) {
|
|
1721
1534
|
const allowedExpressionTypes = /* @__PURE__ */ new Set([
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1535
|
+
AST_NODE_TYPES20.Identifier,
|
|
1536
|
+
AST_NODE_TYPES20.Literal,
|
|
1537
|
+
AST_NODE_TYPES20.JSXElement,
|
|
1538
|
+
AST_NODE_TYPES20.JSXFragment,
|
|
1539
|
+
AST_NODE_TYPES20.MemberExpression,
|
|
1540
|
+
AST_NODE_TYPES20.ArrowFunctionExpression,
|
|
1541
|
+
AST_NODE_TYPES20.FunctionExpression
|
|
1729
1542
|
]);
|
|
1730
1543
|
return {
|
|
1731
1544
|
JSXAttribute(node) {
|
|
1732
1545
|
if (!node.value) {
|
|
1733
1546
|
return;
|
|
1734
1547
|
}
|
|
1735
|
-
if (node.value.type ===
|
|
1548
|
+
if (node.value.type === AST_NODE_TYPES20.Literal) {
|
|
1736
1549
|
return;
|
|
1737
1550
|
}
|
|
1738
|
-
if (node.value.type ===
|
|
1551
|
+
if (node.value.type === AST_NODE_TYPES20.JSXExpressionContainer) {
|
|
1739
1552
|
const { expression } = node.value;
|
|
1740
|
-
if (expression.type ===
|
|
1553
|
+
if (expression.type === AST_NODE_TYPES20.JSXEmptyExpression) {
|
|
1741
1554
|
return;
|
|
1742
1555
|
}
|
|
1743
1556
|
if (!allowedExpressionTypes.has(expression.type)) {
|
|
@@ -1754,8 +1567,8 @@ var jsxSimpleProps = createRule22({
|
|
|
1754
1567
|
var jsx_simple_props_default = jsxSimpleProps;
|
|
1755
1568
|
|
|
1756
1569
|
// src/rules/jsx-sort-props.ts
|
|
1757
|
-
import { AST_NODE_TYPES as
|
|
1758
|
-
var
|
|
1570
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES21, ESLintUtils as ESLintUtils20 } from "@typescript-eslint/utils";
|
|
1571
|
+
var createRule20 = ESLintUtils20.RuleCreator(
|
|
1759
1572
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1760
1573
|
);
|
|
1761
1574
|
var TYPE_GROUP = {
|
|
@@ -1769,15 +1582,15 @@ var TYPE_GROUP = {
|
|
|
1769
1582
|
SHORTHAND: 8
|
|
1770
1583
|
};
|
|
1771
1584
|
var EXPRESSION_TYPE_TO_GROUP = /* @__PURE__ */ new Map([
|
|
1772
|
-
[
|
|
1773
|
-
[
|
|
1774
|
-
[
|
|
1775
|
-
[
|
|
1776
|
-
[
|
|
1777
|
-
[
|
|
1585
|
+
[AST_NODE_TYPES21.ObjectExpression, TYPE_GROUP.OBJECT_ARRAY],
|
|
1586
|
+
[AST_NODE_TYPES21.ArrayExpression, TYPE_GROUP.OBJECT_ARRAY],
|
|
1587
|
+
[AST_NODE_TYPES21.ArrowFunctionExpression, TYPE_GROUP.FUNCTION],
|
|
1588
|
+
[AST_NODE_TYPES21.FunctionExpression, TYPE_GROUP.FUNCTION],
|
|
1589
|
+
[AST_NODE_TYPES21.JSXElement, TYPE_GROUP.JSX],
|
|
1590
|
+
[AST_NODE_TYPES21.JSXFragment, TYPE_GROUP.JSX]
|
|
1778
1591
|
]);
|
|
1779
1592
|
function isHyphenatedName(node) {
|
|
1780
|
-
return node.name.type ===
|
|
1593
|
+
return node.name.type === AST_NODE_TYPES21.JSXIdentifier && node.name.name.includes("-");
|
|
1781
1594
|
}
|
|
1782
1595
|
function getStringGroup(node) {
|
|
1783
1596
|
return isHyphenatedName(node) ? TYPE_GROUP.HYPHENATED_STRING : TYPE_GROUP.STRING;
|
|
@@ -1789,13 +1602,13 @@ function getLiteralValueGroup(value) {
|
|
|
1789
1602
|
return TYPE_GROUP.NUMBER_BOOLEAN_NULL;
|
|
1790
1603
|
}
|
|
1791
1604
|
function getExpressionGroup(expression) {
|
|
1792
|
-
if (expression.type ===
|
|
1605
|
+
if (expression.type === AST_NODE_TYPES21.Literal) {
|
|
1793
1606
|
return getLiteralValueGroup(expression.value);
|
|
1794
1607
|
}
|
|
1795
|
-
if (expression.type ===
|
|
1608
|
+
if (expression.type === AST_NODE_TYPES21.TemplateLiteral) {
|
|
1796
1609
|
return null;
|
|
1797
1610
|
}
|
|
1798
|
-
if (expression.type ===
|
|
1611
|
+
if (expression.type === AST_NODE_TYPES21.Identifier && expression.name === "undefined") {
|
|
1799
1612
|
return TYPE_GROUP.NUMBER_BOOLEAN_NULL;
|
|
1800
1613
|
}
|
|
1801
1614
|
return EXPRESSION_TYPE_TO_GROUP.get(expression.type) ?? TYPE_GROUP.EXPRESSION;
|
|
@@ -1804,17 +1617,17 @@ function getTypeGroup(node) {
|
|
|
1804
1617
|
if (node.value === null) {
|
|
1805
1618
|
return TYPE_GROUP.SHORTHAND;
|
|
1806
1619
|
}
|
|
1807
|
-
if (node.value.type ===
|
|
1620
|
+
if (node.value.type === AST_NODE_TYPES21.Literal) {
|
|
1808
1621
|
if (typeof node.value.value === "string") {
|
|
1809
1622
|
return getStringGroup(node);
|
|
1810
1623
|
}
|
|
1811
1624
|
return TYPE_GROUP.NUMBER_BOOLEAN_NULL;
|
|
1812
1625
|
}
|
|
1813
|
-
if (node.value.type !==
|
|
1626
|
+
if (node.value.type !== AST_NODE_TYPES21.JSXExpressionContainer) {
|
|
1814
1627
|
return null;
|
|
1815
1628
|
}
|
|
1816
1629
|
const { expression } = node.value;
|
|
1817
|
-
if (expression.type ===
|
|
1630
|
+
if (expression.type === AST_NODE_TYPES21.JSXEmptyExpression) {
|
|
1818
1631
|
return null;
|
|
1819
1632
|
}
|
|
1820
1633
|
const group = getExpressionGroup(expression);
|
|
@@ -1826,7 +1639,7 @@ function getTypeGroup(node) {
|
|
|
1826
1639
|
function hasUnsortedProps(attributes) {
|
|
1827
1640
|
let lastGroup = 0;
|
|
1828
1641
|
return attributes.some((attribute) => {
|
|
1829
|
-
if (attribute.type ===
|
|
1642
|
+
if (attribute.type === AST_NODE_TYPES21.JSXSpreadAttribute) {
|
|
1830
1643
|
lastGroup = 0;
|
|
1831
1644
|
return false;
|
|
1832
1645
|
}
|
|
@@ -1850,7 +1663,7 @@ function getSegments(attributes) {
|
|
|
1850
1663
|
const result = [];
|
|
1851
1664
|
let current = [];
|
|
1852
1665
|
attributes.forEach((attr) => {
|
|
1853
|
-
if (attr.type ===
|
|
1666
|
+
if (attr.type === AST_NODE_TYPES21.JSXSpreadAttribute) {
|
|
1854
1667
|
if (current.length > 0) {
|
|
1855
1668
|
result.push(current);
|
|
1856
1669
|
current = [];
|
|
@@ -1864,7 +1677,7 @@ function getSegments(attributes) {
|
|
|
1864
1677
|
}
|
|
1865
1678
|
return result;
|
|
1866
1679
|
}
|
|
1867
|
-
var jsxSortProps =
|
|
1680
|
+
var jsxSortProps = createRule20({
|
|
1868
1681
|
name: "jsx-sort-props",
|
|
1869
1682
|
meta: {
|
|
1870
1683
|
type: "suggestion",
|
|
@@ -1899,11 +1712,11 @@ var jsxSortProps = createRule23({
|
|
|
1899
1712
|
var jsx_sort_props_default = jsxSortProps;
|
|
1900
1713
|
|
|
1901
1714
|
// src/rules/jsx-spread-props-last.ts
|
|
1902
|
-
import { AST_NODE_TYPES as
|
|
1903
|
-
var
|
|
1715
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES22, ESLintUtils as ESLintUtils21 } from "@typescript-eslint/utils";
|
|
1716
|
+
var createRule21 = ESLintUtils21.RuleCreator(
|
|
1904
1717
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1905
1718
|
);
|
|
1906
|
-
var jsxSpreadPropsLast =
|
|
1719
|
+
var jsxSpreadPropsLast = createRule21({
|
|
1907
1720
|
name: "jsx-spread-props-last",
|
|
1908
1721
|
meta: {
|
|
1909
1722
|
type: "suggestion",
|
|
@@ -1922,12 +1735,12 @@ var jsxSpreadPropsLast = createRule24({
|
|
|
1922
1735
|
const { attributes } = node;
|
|
1923
1736
|
let lastNonSpreadIndex = -1;
|
|
1924
1737
|
attributes.forEach((attribute, index) => {
|
|
1925
|
-
if (attribute.type !==
|
|
1738
|
+
if (attribute.type !== AST_NODE_TYPES22.JSXSpreadAttribute) {
|
|
1926
1739
|
lastNonSpreadIndex = index;
|
|
1927
1740
|
}
|
|
1928
1741
|
});
|
|
1929
1742
|
attributes.forEach((attribute, index) => {
|
|
1930
|
-
if (attribute.type ===
|
|
1743
|
+
if (attribute.type === AST_NODE_TYPES22.JSXSpreadAttribute && index < lastNonSpreadIndex) {
|
|
1931
1744
|
context.report({
|
|
1932
1745
|
node: attribute,
|
|
1933
1746
|
messageId: "spreadNotLast"
|
|
@@ -1941,12 +1754,12 @@ var jsxSpreadPropsLast = createRule24({
|
|
|
1941
1754
|
var jsx_spread_props_last_default = jsxSpreadPropsLast;
|
|
1942
1755
|
|
|
1943
1756
|
// src/rules/newline-after-multiline-block.ts
|
|
1944
|
-
import { AST_NODE_TYPES as
|
|
1945
|
-
var
|
|
1757
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES23, ESLintUtils as ESLintUtils22 } from "@typescript-eslint/utils";
|
|
1758
|
+
var createRule22 = ESLintUtils22.RuleCreator(
|
|
1946
1759
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1947
1760
|
);
|
|
1948
1761
|
function isImportDeclaration(node) {
|
|
1949
|
-
return node.type ===
|
|
1762
|
+
return node.type === AST_NODE_TYPES23.ImportDeclaration;
|
|
1950
1763
|
}
|
|
1951
1764
|
function checkStatements(statements, context) {
|
|
1952
1765
|
const { sourceCode } = context;
|
|
@@ -1981,7 +1794,7 @@ function checkStatements(statements, context) {
|
|
|
1981
1794
|
}
|
|
1982
1795
|
});
|
|
1983
1796
|
}
|
|
1984
|
-
var newlineAfterMultilineBlock =
|
|
1797
|
+
var newlineAfterMultilineBlock = createRule22({
|
|
1985
1798
|
name: "newline-after-multiline-block",
|
|
1986
1799
|
meta: {
|
|
1987
1800
|
type: "layout",
|
|
@@ -2009,11 +1822,11 @@ var newlineAfterMultilineBlock = createRule25({
|
|
|
2009
1822
|
var newline_after_multiline_block_default = newlineAfterMultilineBlock;
|
|
2010
1823
|
|
|
2011
1824
|
// src/rules/newline-before-return.ts
|
|
2012
|
-
import { AST_NODE_TYPES as
|
|
2013
|
-
var
|
|
1825
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES24, ESLintUtils as ESLintUtils23 } from "@typescript-eslint/utils";
|
|
1826
|
+
var createRule23 = ESLintUtils23.RuleCreator(
|
|
2014
1827
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2015
1828
|
);
|
|
2016
|
-
var newlineBeforeReturn =
|
|
1829
|
+
var newlineBeforeReturn = createRule23({
|
|
2017
1830
|
name: "newline-before-return",
|
|
2018
1831
|
meta: {
|
|
2019
1832
|
type: "layout",
|
|
@@ -2031,7 +1844,7 @@ var newlineBeforeReturn = createRule26({
|
|
|
2031
1844
|
const { sourceCode } = context;
|
|
2032
1845
|
function checkReturnStatement(node) {
|
|
2033
1846
|
const { parent } = node;
|
|
2034
|
-
if (!parent || parent.type !==
|
|
1847
|
+
if (!parent || parent.type !== AST_NODE_TYPES24.BlockStatement) {
|
|
2035
1848
|
return;
|
|
2036
1849
|
}
|
|
2037
1850
|
const { body: statements } = parent;
|
|
@@ -2067,61 +1880,12 @@ var newlineBeforeReturn = createRule26({
|
|
|
2067
1880
|
});
|
|
2068
1881
|
var newline_before_return_default = newlineBeforeReturn;
|
|
2069
1882
|
|
|
2070
|
-
// src/rules/nextjs-require-public-env.ts
|
|
2071
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES26, ESLintUtils as ESLintUtils27 } from "@typescript-eslint/utils";
|
|
2072
|
-
var createRule27 = ESLintUtils27.RuleCreator(
|
|
2073
|
-
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2074
|
-
);
|
|
2075
|
-
var nextjsRequirePublicEnv = createRule27({
|
|
2076
|
-
name: "nextjs-require-public-env",
|
|
2077
|
-
meta: {
|
|
2078
|
-
type: "problem",
|
|
2079
|
-
docs: {
|
|
2080
|
-
description: "Require NEXT_PUBLIC_ prefix for environment variables in client components"
|
|
2081
|
-
},
|
|
2082
|
-
messages: {
|
|
2083
|
-
requirePublicPrefix: "Environment variable '{{ name }}' must use NEXT_PUBLIC_ prefix in client components. Use 'NEXT_PUBLIC_{{ name }}' instead."
|
|
2084
|
-
},
|
|
2085
|
-
schema: []
|
|
2086
|
-
},
|
|
2087
|
-
defaultOptions: [],
|
|
2088
|
-
create(context) {
|
|
2089
|
-
let isClientComponent = false;
|
|
2090
|
-
return {
|
|
2091
|
-
Program(node) {
|
|
2092
|
-
const firstStatement = node.body[0];
|
|
2093
|
-
if (firstStatement?.type === AST_NODE_TYPES26.ExpressionStatement && firstStatement.expression.type === AST_NODE_TYPES26.Literal && firstStatement.expression.value === "use client") {
|
|
2094
|
-
isClientComponent = true;
|
|
2095
|
-
}
|
|
2096
|
-
},
|
|
2097
|
-
MemberExpression(node) {
|
|
2098
|
-
if (!isClientComponent) {
|
|
2099
|
-
return;
|
|
2100
|
-
}
|
|
2101
|
-
if (node.object.type === AST_NODE_TYPES26.MemberExpression && node.object.object.type === AST_NODE_TYPES26.Identifier && node.object.object.name === "process" && node.object.property.type === AST_NODE_TYPES26.Identifier && node.object.property.name === "env" && node.property.type === AST_NODE_TYPES26.Identifier) {
|
|
2102
|
-
const envVarName = node.property.name;
|
|
2103
|
-
if (!envVarName.startsWith("NEXT_PUBLIC_") && envVarName !== "NODE_ENV") {
|
|
2104
|
-
context.report({
|
|
2105
|
-
node: node.property,
|
|
2106
|
-
messageId: "requirePublicPrefix",
|
|
2107
|
-
data: {
|
|
2108
|
-
name: envVarName
|
|
2109
|
-
}
|
|
2110
|
-
});
|
|
2111
|
-
}
|
|
2112
|
-
}
|
|
2113
|
-
}
|
|
2114
|
-
};
|
|
2115
|
-
}
|
|
2116
|
-
});
|
|
2117
|
-
var nextjs_require_public_env_default = nextjsRequirePublicEnv;
|
|
2118
|
-
|
|
2119
1883
|
// src/rules/no-complex-inline-return.ts
|
|
2120
|
-
import { AST_NODE_TYPES as
|
|
2121
|
-
var
|
|
1884
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES25, ESLintUtils as ESLintUtils24 } from "@typescript-eslint/utils";
|
|
1885
|
+
var createRule24 = ESLintUtils24.RuleCreator(
|
|
2122
1886
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2123
1887
|
);
|
|
2124
|
-
var noComplexInlineReturn =
|
|
1888
|
+
var noComplexInlineReturn = createRule24({
|
|
2125
1889
|
name: "no-complex-inline-return",
|
|
2126
1890
|
meta: {
|
|
2127
1891
|
type: "suggestion",
|
|
@@ -2137,13 +1901,13 @@ var noComplexInlineReturn = createRule28({
|
|
|
2137
1901
|
create(context) {
|
|
2138
1902
|
const isComplexExpression = (node) => {
|
|
2139
1903
|
if (!node) return false;
|
|
2140
|
-
if (node.type ===
|
|
1904
|
+
if (node.type === AST_NODE_TYPES25.ConditionalExpression) {
|
|
2141
1905
|
return true;
|
|
2142
1906
|
}
|
|
2143
|
-
if (node.type ===
|
|
1907
|
+
if (node.type === AST_NODE_TYPES25.LogicalExpression) {
|
|
2144
1908
|
return true;
|
|
2145
1909
|
}
|
|
2146
|
-
if (node.type ===
|
|
1910
|
+
if (node.type === AST_NODE_TYPES25.NewExpression) {
|
|
2147
1911
|
return true;
|
|
2148
1912
|
}
|
|
2149
1913
|
return false;
|
|
@@ -2163,11 +1927,11 @@ var noComplexInlineReturn = createRule28({
|
|
|
2163
1927
|
var no_complex_inline_return_default = noComplexInlineReturn;
|
|
2164
1928
|
|
|
2165
1929
|
// src/rules/no-direct-date.ts
|
|
2166
|
-
import { AST_NODE_TYPES as
|
|
2167
|
-
var
|
|
1930
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES26, ESLintUtils as ESLintUtils25 } from "@typescript-eslint/utils";
|
|
1931
|
+
var createRule25 = ESLintUtils25.RuleCreator(
|
|
2168
1932
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2169
1933
|
);
|
|
2170
|
-
var noDirectDate =
|
|
1934
|
+
var noDirectDate = createRule25({
|
|
2171
1935
|
name: "no-direct-date",
|
|
2172
1936
|
meta: {
|
|
2173
1937
|
type: "problem",
|
|
@@ -2185,7 +1949,7 @@ var noDirectDate = createRule29({
|
|
|
2185
1949
|
create(context) {
|
|
2186
1950
|
return {
|
|
2187
1951
|
NewExpression(node) {
|
|
2188
|
-
if (node.callee.type ===
|
|
1952
|
+
if (node.callee.type === AST_NODE_TYPES26.Identifier && node.callee.name === "Date") {
|
|
2189
1953
|
context.report({
|
|
2190
1954
|
node,
|
|
2191
1955
|
messageId: "noNewDate"
|
|
@@ -2193,7 +1957,7 @@ var noDirectDate = createRule29({
|
|
|
2193
1957
|
}
|
|
2194
1958
|
},
|
|
2195
1959
|
CallExpression(node) {
|
|
2196
|
-
if (node.callee.type ===
|
|
1960
|
+
if (node.callee.type === AST_NODE_TYPES26.MemberExpression && node.callee.object.type === AST_NODE_TYPES26.Identifier && node.callee.object.name === "Date" && node.callee.property.type === AST_NODE_TYPES26.Identifier) {
|
|
2197
1961
|
const methodName = node.callee.property.name;
|
|
2198
1962
|
if (methodName === "now") {
|
|
2199
1963
|
context.report({
|
|
@@ -2216,11 +1980,11 @@ var no_direct_date_default = noDirectDate;
|
|
|
2216
1980
|
|
|
2217
1981
|
// src/rules/no-emoji.ts
|
|
2218
1982
|
import emojiRegex from "emoji-regex";
|
|
2219
|
-
import { ESLintUtils as
|
|
2220
|
-
var
|
|
1983
|
+
import { ESLintUtils as ESLintUtils26 } from "@typescript-eslint/utils";
|
|
1984
|
+
var createRule26 = ESLintUtils26.RuleCreator(
|
|
2221
1985
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2222
1986
|
);
|
|
2223
|
-
var noEmoji =
|
|
1987
|
+
var noEmoji = createRule26({
|
|
2224
1988
|
name: "no-emoji",
|
|
2225
1989
|
meta: {
|
|
2226
1990
|
type: "problem",
|
|
@@ -2254,11 +2018,11 @@ var noEmoji = createRule30({
|
|
|
2254
2018
|
var no_emoji_default = noEmoji;
|
|
2255
2019
|
|
|
2256
2020
|
// src/rules/no-env-fallback.ts
|
|
2257
|
-
import { AST_NODE_TYPES as
|
|
2258
|
-
var
|
|
2021
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES27, ESLintUtils as ESLintUtils27 } from "@typescript-eslint/utils";
|
|
2022
|
+
var createRule27 = ESLintUtils27.RuleCreator(
|
|
2259
2023
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2260
2024
|
);
|
|
2261
|
-
var noEnvFallback =
|
|
2025
|
+
var noEnvFallback = createRule27({
|
|
2262
2026
|
name: "no-env-fallback",
|
|
2263
2027
|
meta: {
|
|
2264
2028
|
type: "problem",
|
|
@@ -2273,16 +2037,16 @@ var noEnvFallback = createRule31({
|
|
|
2273
2037
|
defaultOptions: [],
|
|
2274
2038
|
create(context) {
|
|
2275
2039
|
const isProcessEnvAccess = (node) => {
|
|
2276
|
-
if (node.type !==
|
|
2040
|
+
if (node.type !== AST_NODE_TYPES27.MemberExpression) {
|
|
2277
2041
|
return false;
|
|
2278
2042
|
}
|
|
2279
2043
|
const { object } = node;
|
|
2280
|
-
if (object.type !==
|
|
2044
|
+
if (object.type !== AST_NODE_TYPES27.MemberExpression) {
|
|
2281
2045
|
return false;
|
|
2282
2046
|
}
|
|
2283
2047
|
const processNode = object.object;
|
|
2284
2048
|
const envNode = object.property;
|
|
2285
|
-
return processNode.type ===
|
|
2049
|
+
return processNode.type === AST_NODE_TYPES27.Identifier && processNode.name === "process" && envNode.type === AST_NODE_TYPES27.Identifier && envNode.name === "env";
|
|
2286
2050
|
};
|
|
2287
2051
|
return {
|
|
2288
2052
|
LogicalExpression(node) {
|
|
@@ -2307,11 +2071,11 @@ var noEnvFallback = createRule31({
|
|
|
2307
2071
|
var no_env_fallback_default = noEnvFallback;
|
|
2308
2072
|
|
|
2309
2073
|
// src/rules/no-inline-default-export.ts
|
|
2310
|
-
import { AST_NODE_TYPES as
|
|
2311
|
-
var
|
|
2074
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES28, ESLintUtils as ESLintUtils28 } from "@typescript-eslint/utils";
|
|
2075
|
+
var createRule28 = ESLintUtils28.RuleCreator(
|
|
2312
2076
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2313
2077
|
);
|
|
2314
|
-
var noInlineDefaultExport =
|
|
2078
|
+
var noInlineDefaultExport = createRule28({
|
|
2315
2079
|
name: "no-inline-default-export",
|
|
2316
2080
|
meta: {
|
|
2317
2081
|
type: "suggestion",
|
|
@@ -2330,7 +2094,7 @@ var noInlineDefaultExport = createRule32({
|
|
|
2330
2094
|
return {
|
|
2331
2095
|
ExportDefaultDeclaration(node) {
|
|
2332
2096
|
const { declaration } = node;
|
|
2333
|
-
if (declaration.type ===
|
|
2097
|
+
if (declaration.type === AST_NODE_TYPES28.FunctionDeclaration) {
|
|
2334
2098
|
if (declaration.id) {
|
|
2335
2099
|
context.report({
|
|
2336
2100
|
node,
|
|
@@ -2345,7 +2109,7 @@ var noInlineDefaultExport = createRule32({
|
|
|
2345
2109
|
});
|
|
2346
2110
|
}
|
|
2347
2111
|
}
|
|
2348
|
-
if (declaration.type ===
|
|
2112
|
+
if (declaration.type === AST_NODE_TYPES28.ClassDeclaration) {
|
|
2349
2113
|
if (declaration.id) {
|
|
2350
2114
|
context.report({
|
|
2351
2115
|
node,
|
|
@@ -2360,7 +2124,7 @@ var noInlineDefaultExport = createRule32({
|
|
|
2360
2124
|
});
|
|
2361
2125
|
}
|
|
2362
2126
|
}
|
|
2363
|
-
if (declaration.type ===
|
|
2127
|
+
if (declaration.type === AST_NODE_TYPES28.ArrowFunctionExpression || declaration.type === AST_NODE_TYPES28.FunctionExpression) {
|
|
2364
2128
|
context.report({
|
|
2365
2129
|
node,
|
|
2366
2130
|
messageId: "noAnonymousDefaultExport",
|
|
@@ -2373,14 +2137,14 @@ var noInlineDefaultExport = createRule32({
|
|
|
2373
2137
|
if (!declaration) {
|
|
2374
2138
|
return;
|
|
2375
2139
|
}
|
|
2376
|
-
if (declaration.type ===
|
|
2140
|
+
if (declaration.type === AST_NODE_TYPES28.FunctionDeclaration && declaration.id) {
|
|
2377
2141
|
context.report({
|
|
2378
2142
|
node,
|
|
2379
2143
|
messageId: "noInlineNamedExport",
|
|
2380
2144
|
data: { type: "function", name: declaration.id.name }
|
|
2381
2145
|
});
|
|
2382
2146
|
}
|
|
2383
|
-
if (declaration.type ===
|
|
2147
|
+
if (declaration.type === AST_NODE_TYPES28.ClassDeclaration && declaration.id) {
|
|
2384
2148
|
context.report({
|
|
2385
2149
|
node,
|
|
2386
2150
|
messageId: "noInlineNamedExport",
|
|
@@ -2394,36 +2158,45 @@ var noInlineDefaultExport = createRule32({
|
|
|
2394
2158
|
var no_inline_default_export_default = noInlineDefaultExport;
|
|
2395
2159
|
|
|
2396
2160
|
// src/rules/no-inline-nested-object.ts
|
|
2397
|
-
import { AST_NODE_TYPES as
|
|
2398
|
-
var
|
|
2161
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES29, ESLintUtils as ESLintUtils29 } from "@typescript-eslint/utils";
|
|
2162
|
+
var createRule29 = ESLintUtils29.RuleCreator(
|
|
2399
2163
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2400
2164
|
);
|
|
2401
2165
|
function isObjectOrArray(node) {
|
|
2402
|
-
return node.type ===
|
|
2166
|
+
return node.type === AST_NODE_TYPES29.ObjectExpression || node.type === AST_NODE_TYPES29.ArrayExpression || node.type === AST_NODE_TYPES29.TSAsExpression;
|
|
2403
2167
|
}
|
|
2404
2168
|
function getInnerExpression(node) {
|
|
2405
|
-
if (node.type ===
|
|
2169
|
+
if (node.type === AST_NODE_TYPES29.TSAsExpression) {
|
|
2406
2170
|
return getInnerExpression(node.expression);
|
|
2407
2171
|
}
|
|
2408
2172
|
return node;
|
|
2409
2173
|
}
|
|
2410
|
-
function
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
|
|
2414
|
-
|
|
2174
|
+
function isNestedStructure(node) {
|
|
2175
|
+
const inner = getInnerExpression(node);
|
|
2176
|
+
return inner.type === AST_NODE_TYPES29.ObjectExpression || inner.type === AST_NODE_TYPES29.ArrayExpression;
|
|
2177
|
+
}
|
|
2178
|
+
function containsNestedStructure(node) {
|
|
2179
|
+
if (node.type === AST_NODE_TYPES29.ObjectExpression) {
|
|
2180
|
+
return node.properties.some((prop) => {
|
|
2181
|
+
if (prop.type !== AST_NODE_TYPES29.Property) return false;
|
|
2182
|
+
return isNestedStructure(prop.value);
|
|
2183
|
+
});
|
|
2184
|
+
}
|
|
2185
|
+
return node.elements.some((el) => {
|
|
2186
|
+
if (el === null) return false;
|
|
2187
|
+
return isNestedStructure(el);
|
|
2415
2188
|
});
|
|
2416
2189
|
}
|
|
2417
|
-
var noInlineNestedObject =
|
|
2190
|
+
var noInlineNestedObject = createRule29({
|
|
2418
2191
|
name: "no-inline-nested-object",
|
|
2419
2192
|
meta: {
|
|
2420
2193
|
type: "layout",
|
|
2421
2194
|
docs: {
|
|
2422
|
-
description: "Require nested objects
|
|
2195
|
+
description: "Require object or array values that contain further nested objects or arrays to span multiple lines"
|
|
2423
2196
|
},
|
|
2424
2197
|
fixable: "whitespace",
|
|
2425
2198
|
messages: {
|
|
2426
|
-
requireMultiline: "
|
|
2199
|
+
requireMultiline: "Inline collections containing nested objects or arrays should span multiple lines"
|
|
2427
2200
|
},
|
|
2428
2201
|
schema: []
|
|
2429
2202
|
},
|
|
@@ -2436,23 +2209,20 @@ var noInlineNestedObject = createRule33({
|
|
|
2436
2209
|
return;
|
|
2437
2210
|
}
|
|
2438
2211
|
const valueNode = getInnerExpression(node.value);
|
|
2439
|
-
if (valueNode.type !==
|
|
2212
|
+
if (valueNode.type !== AST_NODE_TYPES29.ObjectExpression && valueNode.type !== AST_NODE_TYPES29.ArrayExpression) {
|
|
2440
2213
|
return;
|
|
2441
2214
|
}
|
|
2442
2215
|
if (!valueNode.loc) {
|
|
2443
2216
|
return;
|
|
2444
2217
|
}
|
|
2445
|
-
const elements = valueNode.type === AST_NODE_TYPES31.ObjectExpression ? valueNode.properties : valueNode.elements;
|
|
2446
|
-
if (elements.length <= 1) {
|
|
2447
|
-
return;
|
|
2448
|
-
}
|
|
2449
|
-
if (valueNode.type === AST_NODE_TYPES31.ArrayExpression && arrayContainsOnlyPrimitives(valueNode)) {
|
|
2450
|
-
return;
|
|
2451
|
-
}
|
|
2452
2218
|
const isMultiline = valueNode.loc.start.line !== valueNode.loc.end.line;
|
|
2453
2219
|
if (isMultiline) {
|
|
2454
2220
|
return;
|
|
2455
2221
|
}
|
|
2222
|
+
if (!containsNestedStructure(valueNode)) {
|
|
2223
|
+
return;
|
|
2224
|
+
}
|
|
2225
|
+
const elements = valueNode.type === AST_NODE_TYPES29.ObjectExpression ? valueNode.properties : valueNode.elements;
|
|
2456
2226
|
context.report({
|
|
2457
2227
|
node: valueNode,
|
|
2458
2228
|
messageId: "requireMultiline",
|
|
@@ -2465,7 +2235,7 @@ var noInlineNestedObject = createRule33({
|
|
|
2465
2235
|
const indent = " ".repeat(node.loc?.start.column ?? 0);
|
|
2466
2236
|
const innerIndent = `${indent} `;
|
|
2467
2237
|
const elementTexts = elements.filter((el) => el !== null).map((el) => sourceCode.getText(el));
|
|
2468
|
-
const isObject = valueNode.type ===
|
|
2238
|
+
const isObject = valueNode.type === AST_NODE_TYPES29.ObjectExpression;
|
|
2469
2239
|
const openChar = isObject ? "{" : "[";
|
|
2470
2240
|
const closeChar = isObject ? "}" : "]";
|
|
2471
2241
|
const formattedElements = elementTexts.map((text) => `${innerIndent}${text},`).join("\n");
|
|
@@ -2482,20 +2252,20 @@ ${indent}${closeChar}`;
|
|
|
2482
2252
|
var no_inline_nested_object_default = noInlineNestedObject;
|
|
2483
2253
|
|
|
2484
2254
|
// src/rules/no-inline-return-properties.ts
|
|
2485
|
-
import { AST_NODE_TYPES as
|
|
2486
|
-
var
|
|
2255
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES30, ESLintUtils as ESLintUtils30 } from "@typescript-eslint/utils";
|
|
2256
|
+
var createRule30 = ESLintUtils30.RuleCreator(
|
|
2487
2257
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2488
2258
|
);
|
|
2489
2259
|
var isShorthandProperty = (property) => {
|
|
2490
|
-
if (property.type ===
|
|
2260
|
+
if (property.type === AST_NODE_TYPES30.SpreadElement) {
|
|
2491
2261
|
return true;
|
|
2492
2262
|
}
|
|
2493
|
-
if (property.type !==
|
|
2263
|
+
if (property.type !== AST_NODE_TYPES30.Property) {
|
|
2494
2264
|
return false;
|
|
2495
2265
|
}
|
|
2496
2266
|
return property.shorthand;
|
|
2497
2267
|
};
|
|
2498
|
-
var noInlineReturnProperties =
|
|
2268
|
+
var noInlineReturnProperties = createRule30({
|
|
2499
2269
|
name: "no-inline-return-properties",
|
|
2500
2270
|
meta: {
|
|
2501
2271
|
type: "suggestion",
|
|
@@ -2511,20 +2281,20 @@ var noInlineReturnProperties = createRule34({
|
|
|
2511
2281
|
create(context) {
|
|
2512
2282
|
return {
|
|
2513
2283
|
ReturnStatement(node) {
|
|
2514
|
-
if (!node.argument || node.argument.type !==
|
|
2284
|
+
if (!node.argument || node.argument.type !== AST_NODE_TYPES30.ObjectExpression) {
|
|
2515
2285
|
return;
|
|
2516
2286
|
}
|
|
2517
2287
|
node.argument.properties.forEach((property) => {
|
|
2518
2288
|
if (isShorthandProperty(property)) {
|
|
2519
2289
|
return;
|
|
2520
2290
|
}
|
|
2521
|
-
if (property.type !==
|
|
2291
|
+
if (property.type !== AST_NODE_TYPES30.Property) {
|
|
2522
2292
|
return;
|
|
2523
2293
|
}
|
|
2524
2294
|
let keyName = null;
|
|
2525
|
-
if (property.key.type ===
|
|
2295
|
+
if (property.key.type === AST_NODE_TYPES30.Identifier) {
|
|
2526
2296
|
keyName = property.key.name;
|
|
2527
|
-
} else if (property.key.type ===
|
|
2297
|
+
} else if (property.key.type === AST_NODE_TYPES30.Literal) {
|
|
2528
2298
|
keyName = String(property.key.value);
|
|
2529
2299
|
}
|
|
2530
2300
|
context.report({
|
|
@@ -2540,12 +2310,12 @@ var noInlineReturnProperties = createRule34({
|
|
|
2540
2310
|
var no_inline_return_properties_default = noInlineReturnProperties;
|
|
2541
2311
|
|
|
2542
2312
|
// src/rules/no-inline-type-import.ts
|
|
2543
|
-
import { AST_NODE_TYPES as
|
|
2544
|
-
var
|
|
2313
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES31, ESLintUtils as ESLintUtils31 } from "@typescript-eslint/utils";
|
|
2314
|
+
var createRule31 = ESLintUtils31.RuleCreator(
|
|
2545
2315
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2546
2316
|
);
|
|
2547
|
-
var isInlineTypeSpecifier = (specifier) => specifier.type ===
|
|
2548
|
-
var noInlineTypeImport =
|
|
2317
|
+
var isInlineTypeSpecifier = (specifier) => specifier.type === AST_NODE_TYPES31.ImportSpecifier && specifier.importKind === "type";
|
|
2318
|
+
var noInlineTypeImport = createRule31({
|
|
2549
2319
|
name: "no-inline-type-import",
|
|
2550
2320
|
meta: {
|
|
2551
2321
|
type: "suggestion",
|
|
@@ -2582,7 +2352,7 @@ var noInlineTypeImport = createRule35({
|
|
|
2582
2352
|
);
|
|
2583
2353
|
const typeImport = `import type { ${typeSpecifierTexts.join(", ")} } from ${sourceText};`;
|
|
2584
2354
|
const valueSpecifiers = node.specifiers.filter(
|
|
2585
|
-
(specifier) => !(specifier.type ===
|
|
2355
|
+
(specifier) => !(specifier.type === AST_NODE_TYPES31.ImportSpecifier && specifier.importKind === "type")
|
|
2586
2356
|
);
|
|
2587
2357
|
if (valueSpecifiers.length === 0) {
|
|
2588
2358
|
return fixer.replaceText(node, typeImport);
|
|
@@ -2590,11 +2360,11 @@ var noInlineTypeImport = createRule35({
|
|
|
2590
2360
|
const parts = [];
|
|
2591
2361
|
const namedValueSpecifiers = [];
|
|
2592
2362
|
for (const specifier of valueSpecifiers) {
|
|
2593
|
-
if (specifier.type ===
|
|
2363
|
+
if (specifier.type === AST_NODE_TYPES31.ImportDefaultSpecifier) {
|
|
2594
2364
|
parts.push(specifier.local.name);
|
|
2595
|
-
} else if (specifier.type ===
|
|
2365
|
+
} else if (specifier.type === AST_NODE_TYPES31.ImportNamespaceSpecifier) {
|
|
2596
2366
|
parts.push(`* as ${specifier.local.name}`);
|
|
2597
|
-
} else if (specifier.type ===
|
|
2367
|
+
} else if (specifier.type === AST_NODE_TYPES31.ImportSpecifier) {
|
|
2598
2368
|
namedValueSpecifiers.push(specifier);
|
|
2599
2369
|
}
|
|
2600
2370
|
}
|
|
@@ -2614,8 +2384,8 @@ ${typeImport}`);
|
|
|
2614
2384
|
var no_inline_type_import_default = noInlineTypeImport;
|
|
2615
2385
|
|
|
2616
2386
|
// src/rules/no-lazy-identifiers.ts
|
|
2617
|
-
import { AST_NODE_TYPES as
|
|
2618
|
-
var
|
|
2387
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES32, ESLintUtils as ESLintUtils32 } from "@typescript-eslint/utils";
|
|
2388
|
+
var createRule32 = ESLintUtils32.RuleCreator(
|
|
2619
2389
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2620
2390
|
);
|
|
2621
2391
|
var KEYBOARD_ROWS = ["qwertyuiop", "asdfghjkl", "zxcvbnm", "1234567890"];
|
|
@@ -2656,7 +2426,7 @@ var isLazyIdentifier = (name) => {
|
|
|
2656
2426
|
}
|
|
2657
2427
|
return false;
|
|
2658
2428
|
};
|
|
2659
|
-
var noLazyIdentifiers =
|
|
2429
|
+
var noLazyIdentifiers = createRule32({
|
|
2660
2430
|
name: "no-lazy-identifiers",
|
|
2661
2431
|
meta: {
|
|
2662
2432
|
type: "problem",
|
|
@@ -2682,27 +2452,27 @@ var noLazyIdentifiers = createRule36({
|
|
|
2682
2452
|
});
|
|
2683
2453
|
};
|
|
2684
2454
|
const checkPattern = (pattern) => {
|
|
2685
|
-
if (pattern.type ===
|
|
2455
|
+
if (pattern.type === AST_NODE_TYPES32.Identifier) {
|
|
2686
2456
|
checkIdentifier(pattern);
|
|
2687
|
-
} else if (pattern.type ===
|
|
2457
|
+
} else if (pattern.type === AST_NODE_TYPES32.ObjectPattern) {
|
|
2688
2458
|
pattern.properties.forEach((prop) => {
|
|
2689
|
-
if (prop.type ===
|
|
2459
|
+
if (prop.type === AST_NODE_TYPES32.Property && prop.value.type === AST_NODE_TYPES32.Identifier) {
|
|
2690
2460
|
checkIdentifier(prop.value);
|
|
2691
|
-
} else if (prop.type ===
|
|
2461
|
+
} else if (prop.type === AST_NODE_TYPES32.RestElement && prop.argument.type === AST_NODE_TYPES32.Identifier) {
|
|
2692
2462
|
checkIdentifier(prop.argument);
|
|
2693
2463
|
}
|
|
2694
2464
|
});
|
|
2695
|
-
} else if (pattern.type ===
|
|
2465
|
+
} else if (pattern.type === AST_NODE_TYPES32.ArrayPattern) {
|
|
2696
2466
|
pattern.elements.forEach((element) => {
|
|
2697
|
-
if (element?.type ===
|
|
2467
|
+
if (element?.type === AST_NODE_TYPES32.Identifier) {
|
|
2698
2468
|
checkIdentifier(element);
|
|
2699
|
-
} else if (element?.type ===
|
|
2469
|
+
} else if (element?.type === AST_NODE_TYPES32.RestElement && element.argument.type === AST_NODE_TYPES32.Identifier) {
|
|
2700
2470
|
checkIdentifier(element.argument);
|
|
2701
2471
|
}
|
|
2702
2472
|
});
|
|
2703
|
-
} else if (pattern.type ===
|
|
2473
|
+
} else if (pattern.type === AST_NODE_TYPES32.AssignmentPattern && pattern.left.type === AST_NODE_TYPES32.Identifier) {
|
|
2704
2474
|
checkIdentifier(pattern.left);
|
|
2705
|
-
} else if (pattern.type ===
|
|
2475
|
+
} else if (pattern.type === AST_NODE_TYPES32.RestElement && pattern.argument.type === AST_NODE_TYPES32.Identifier) {
|
|
2706
2476
|
checkIdentifier(pattern.argument);
|
|
2707
2477
|
}
|
|
2708
2478
|
};
|
|
@@ -2747,11 +2517,11 @@ var noLazyIdentifiers = createRule36({
|
|
|
2747
2517
|
var no_lazy_identifiers_default = noLazyIdentifiers;
|
|
2748
2518
|
|
|
2749
2519
|
// src/rules/no-logic-in-params.ts
|
|
2750
|
-
import { AST_NODE_TYPES as
|
|
2751
|
-
var
|
|
2520
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES33, ESLintUtils as ESLintUtils33 } from "@typescript-eslint/utils";
|
|
2521
|
+
var createRule33 = ESLintUtils33.RuleCreator(
|
|
2752
2522
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2753
2523
|
);
|
|
2754
|
-
var noLogicInParams =
|
|
2524
|
+
var noLogicInParams = createRule33({
|
|
2755
2525
|
name: "no-logic-in-params",
|
|
2756
2526
|
meta: {
|
|
2757
2527
|
type: "suggestion",
|
|
@@ -2766,20 +2536,20 @@ var noLogicInParams = createRule37({
|
|
|
2766
2536
|
defaultOptions: [],
|
|
2767
2537
|
create(context) {
|
|
2768
2538
|
const isComplexExpression = (node) => {
|
|
2769
|
-
if (node.type ===
|
|
2539
|
+
if (node.type === AST_NODE_TYPES33.SpreadElement) {
|
|
2770
2540
|
return false;
|
|
2771
2541
|
}
|
|
2772
|
-
if (node.type ===
|
|
2542
|
+
if (node.type === AST_NODE_TYPES33.ConditionalExpression) {
|
|
2773
2543
|
return true;
|
|
2774
2544
|
}
|
|
2775
|
-
if (node.type ===
|
|
2545
|
+
if (node.type === AST_NODE_TYPES33.LogicalExpression) {
|
|
2776
2546
|
return true;
|
|
2777
2547
|
}
|
|
2778
|
-
if (node.type ===
|
|
2548
|
+
if (node.type === AST_NODE_TYPES33.BinaryExpression) {
|
|
2779
2549
|
const logicalOperators = ["==", "===", "!=", "!==", "<", ">", "<=", ">=", "in", "instanceof"];
|
|
2780
2550
|
return logicalOperators.includes(node.operator);
|
|
2781
2551
|
}
|
|
2782
|
-
if (node.type ===
|
|
2552
|
+
if (node.type === AST_NODE_TYPES33.UnaryExpression) {
|
|
2783
2553
|
return node.operator === "!";
|
|
2784
2554
|
}
|
|
2785
2555
|
return false;
|
|
@@ -2792,7 +2562,7 @@ var noLogicInParams = createRule37({
|
|
|
2792
2562
|
messageId: "noLogicInParams"
|
|
2793
2563
|
});
|
|
2794
2564
|
}
|
|
2795
|
-
if (arg.type ===
|
|
2565
|
+
if (arg.type === AST_NODE_TYPES33.ArrayExpression) {
|
|
2796
2566
|
arg.elements.forEach((element) => {
|
|
2797
2567
|
if (element && isComplexExpression(element)) {
|
|
2798
2568
|
context.report({
|
|
@@ -2817,46 +2587,46 @@ var noLogicInParams = createRule37({
|
|
|
2817
2587
|
var no_logic_in_params_default = noLogicInParams;
|
|
2818
2588
|
|
|
2819
2589
|
// src/rules/no-misleading-constant-case.ts
|
|
2820
|
-
import { AST_NODE_TYPES as
|
|
2821
|
-
var
|
|
2590
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES34, ESLintUtils as ESLintUtils34 } from "@typescript-eslint/utils";
|
|
2591
|
+
var createRule34 = ESLintUtils34.RuleCreator(
|
|
2822
2592
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2823
2593
|
);
|
|
2824
2594
|
var SCREAMING_SNAKE_CASE_REGEX3 = /^[A-Z][A-Z0-9]*(?:_[A-Z0-9]+)*$/;
|
|
2825
|
-
var
|
|
2826
|
-
var
|
|
2827
|
-
if (
|
|
2595
|
+
var isAsConstAssertion = (node) => node.type === AST_NODE_TYPES34.TSAsExpression && node.typeAnnotation.type === AST_NODE_TYPES34.TSTypeReference && node.typeAnnotation.typeName.type === AST_NODE_TYPES34.Identifier && node.typeAnnotation.typeName.name === "const";
|
|
2596
|
+
var isStaticValue2 = (init) => {
|
|
2597
|
+
if (isAsConstAssertion(init)) {
|
|
2828
2598
|
return true;
|
|
2829
2599
|
}
|
|
2830
|
-
if (init.type ===
|
|
2600
|
+
if (init.type === AST_NODE_TYPES34.Literal) {
|
|
2831
2601
|
return true;
|
|
2832
2602
|
}
|
|
2833
|
-
if (init.type ===
|
|
2603
|
+
if (init.type === AST_NODE_TYPES34.UnaryExpression && init.argument.type === AST_NODE_TYPES34.Literal) {
|
|
2834
2604
|
return true;
|
|
2835
2605
|
}
|
|
2836
|
-
if (init.type ===
|
|
2606
|
+
if (init.type === AST_NODE_TYPES34.TemplateLiteral && init.expressions.length === 0) {
|
|
2837
2607
|
return true;
|
|
2838
2608
|
}
|
|
2839
|
-
if (init.type ===
|
|
2840
|
-
return init.elements.every((el) => el !== null && el.type !==
|
|
2609
|
+
if (init.type === AST_NODE_TYPES34.ArrayExpression) {
|
|
2610
|
+
return init.elements.every((el) => el !== null && el.type !== AST_NODE_TYPES34.SpreadElement && isStaticValue2(el));
|
|
2841
2611
|
}
|
|
2842
|
-
if (init.type ===
|
|
2612
|
+
if (init.type === AST_NODE_TYPES34.ObjectExpression) {
|
|
2843
2613
|
return init.properties.every(
|
|
2844
|
-
(prop) => prop.type ===
|
|
2614
|
+
(prop) => prop.type === AST_NODE_TYPES34.Property && isStaticValue2(prop.value)
|
|
2845
2615
|
);
|
|
2846
2616
|
}
|
|
2847
2617
|
return false;
|
|
2848
2618
|
};
|
|
2849
2619
|
var isGlobalScope3 = (node) => {
|
|
2850
2620
|
const { parent } = node;
|
|
2851
|
-
if (parent.type ===
|
|
2621
|
+
if (parent.type === AST_NODE_TYPES34.Program) {
|
|
2852
2622
|
return true;
|
|
2853
2623
|
}
|
|
2854
|
-
if (parent.type ===
|
|
2624
|
+
if (parent.type === AST_NODE_TYPES34.ExportNamedDeclaration && parent.parent?.type === AST_NODE_TYPES34.Program) {
|
|
2855
2625
|
return true;
|
|
2856
2626
|
}
|
|
2857
2627
|
return false;
|
|
2858
2628
|
};
|
|
2859
|
-
var noMisleadingConstantCase =
|
|
2629
|
+
var noMisleadingConstantCase = createRule34({
|
|
2860
2630
|
name: "no-misleading-constant-case",
|
|
2861
2631
|
meta: {
|
|
2862
2632
|
type: "suggestion",
|
|
@@ -2875,7 +2645,7 @@ var noMisleadingConstantCase = createRule38({
|
|
|
2875
2645
|
return {
|
|
2876
2646
|
VariableDeclaration(node) {
|
|
2877
2647
|
node.declarations.forEach((declarator) => {
|
|
2878
|
-
if (declarator.id.type !==
|
|
2648
|
+
if (declarator.id.type !== AST_NODE_TYPES34.Identifier) {
|
|
2879
2649
|
return;
|
|
2880
2650
|
}
|
|
2881
2651
|
const { name } = declarator.id;
|
|
@@ -2901,7 +2671,7 @@ var noMisleadingConstantCase = createRule38({
|
|
|
2901
2671
|
if (!declarator.init) {
|
|
2902
2672
|
return;
|
|
2903
2673
|
}
|
|
2904
|
-
if (!
|
|
2674
|
+
if (!isStaticValue2(declarator.init)) {
|
|
2905
2675
|
context.report({
|
|
2906
2676
|
node: declarator.id,
|
|
2907
2677
|
messageId: "dynamicScreamingCase",
|
|
@@ -2916,11 +2686,11 @@ var noMisleadingConstantCase = createRule38({
|
|
|
2916
2686
|
var no_misleading_constant_case_default = noMisleadingConstantCase;
|
|
2917
2687
|
|
|
2918
2688
|
// src/rules/no-nested-interface-declaration.ts
|
|
2919
|
-
import { AST_NODE_TYPES as
|
|
2920
|
-
var
|
|
2689
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES35, ESLintUtils as ESLintUtils35 } from "@typescript-eslint/utils";
|
|
2690
|
+
var createRule35 = ESLintUtils35.RuleCreator(
|
|
2921
2691
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2922
2692
|
);
|
|
2923
|
-
var noNestedInterfaceDeclaration =
|
|
2693
|
+
var noNestedInterfaceDeclaration = createRule35({
|
|
2924
2694
|
name: "no-nested-interface-declaration",
|
|
2925
2695
|
meta: {
|
|
2926
2696
|
type: "suggestion",
|
|
@@ -2941,15 +2711,15 @@ var noNestedInterfaceDeclaration = createRule39({
|
|
|
2941
2711
|
return;
|
|
2942
2712
|
}
|
|
2943
2713
|
const { typeAnnotation } = node.typeAnnotation;
|
|
2944
|
-
if (typeAnnotation.type ===
|
|
2714
|
+
if (typeAnnotation.type === AST_NODE_TYPES35.TSTypeLiteral) {
|
|
2945
2715
|
context.report({
|
|
2946
2716
|
node: typeAnnotation,
|
|
2947
2717
|
messageId: "noNestedInterface"
|
|
2948
2718
|
});
|
|
2949
2719
|
return;
|
|
2950
2720
|
}
|
|
2951
|
-
if (typeAnnotation.type ===
|
|
2952
|
-
if (typeAnnotation.elementType.type ===
|
|
2721
|
+
if (typeAnnotation.type === AST_NODE_TYPES35.TSArrayType) {
|
|
2722
|
+
if (typeAnnotation.elementType.type === AST_NODE_TYPES35.TSTypeLiteral) {
|
|
2953
2723
|
context.report({
|
|
2954
2724
|
node: typeAnnotation.elementType,
|
|
2955
2725
|
messageId: "noNestedInterface"
|
|
@@ -2957,9 +2727,9 @@ var noNestedInterfaceDeclaration = createRule39({
|
|
|
2957
2727
|
}
|
|
2958
2728
|
return;
|
|
2959
2729
|
}
|
|
2960
|
-
if (typeAnnotation.type ===
|
|
2730
|
+
if (typeAnnotation.type === AST_NODE_TYPES35.TSTypeReference && typeAnnotation.typeArguments) {
|
|
2961
2731
|
typeAnnotation.typeArguments.params.forEach((param) => {
|
|
2962
|
-
if (param.type ===
|
|
2732
|
+
if (param.type === AST_NODE_TYPES35.TSTypeLiteral) {
|
|
2963
2733
|
context.report({
|
|
2964
2734
|
node: param,
|
|
2965
2735
|
messageId: "noNestedInterface"
|
|
@@ -2974,11 +2744,11 @@ var noNestedInterfaceDeclaration = createRule39({
|
|
|
2974
2744
|
var no_nested_interface_declaration_default = noNestedInterfaceDeclaration;
|
|
2975
2745
|
|
|
2976
2746
|
// src/rules/no-nested-ternary.ts
|
|
2977
|
-
import { AST_NODE_TYPES as
|
|
2978
|
-
var
|
|
2747
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES36, ESLintUtils as ESLintUtils36 } from "@typescript-eslint/utils";
|
|
2748
|
+
var createRule36 = ESLintUtils36.RuleCreator(
|
|
2979
2749
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2980
2750
|
);
|
|
2981
|
-
var noNestedTernary =
|
|
2751
|
+
var noNestedTernary = createRule36({
|
|
2982
2752
|
name: "no-nested-ternary",
|
|
2983
2753
|
meta: {
|
|
2984
2754
|
type: "suggestion",
|
|
@@ -2995,13 +2765,13 @@ var noNestedTernary = createRule40({
|
|
|
2995
2765
|
return {
|
|
2996
2766
|
ConditionalExpression(node) {
|
|
2997
2767
|
const { consequent, alternate } = node;
|
|
2998
|
-
if (consequent.type ===
|
|
2768
|
+
if (consequent.type === AST_NODE_TYPES36.ConditionalExpression) {
|
|
2999
2769
|
context.report({
|
|
3000
2770
|
node: consequent,
|
|
3001
2771
|
messageId: "noNestedTernary"
|
|
3002
2772
|
});
|
|
3003
2773
|
}
|
|
3004
|
-
if (alternate.type ===
|
|
2774
|
+
if (alternate.type === AST_NODE_TYPES36.ConditionalExpression) {
|
|
3005
2775
|
context.report({
|
|
3006
2776
|
node: alternate,
|
|
3007
2777
|
messageId: "noNestedTernary"
|
|
@@ -3014,11 +2784,11 @@ var noNestedTernary = createRule40({
|
|
|
3014
2784
|
var no_nested_ternary_default = noNestedTernary;
|
|
3015
2785
|
|
|
3016
2786
|
// src/rules/no-relative-imports.ts
|
|
3017
|
-
import { AST_NODE_TYPES as
|
|
3018
|
-
var
|
|
2787
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES37, ESLintUtils as ESLintUtils37 } from "@typescript-eslint/utils";
|
|
2788
|
+
var createRule37 = ESLintUtils37.RuleCreator(
|
|
3019
2789
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3020
2790
|
);
|
|
3021
|
-
var noRelativeImports =
|
|
2791
|
+
var noRelativeImports = createRule37({
|
|
3022
2792
|
name: "no-relative-imports",
|
|
3023
2793
|
meta: {
|
|
3024
2794
|
type: "suggestion",
|
|
@@ -3042,22 +2812,22 @@ var noRelativeImports = createRule41({
|
|
|
3042
2812
|
};
|
|
3043
2813
|
return {
|
|
3044
2814
|
ImportDeclaration(node) {
|
|
3045
|
-
if (node.source.type ===
|
|
2815
|
+
if (node.source.type === AST_NODE_TYPES37.Literal && typeof node.source.value === "string") {
|
|
3046
2816
|
checkImportPath(node.source.value, node);
|
|
3047
2817
|
}
|
|
3048
2818
|
},
|
|
3049
2819
|
ImportExpression(node) {
|
|
3050
|
-
if (node.source.type ===
|
|
2820
|
+
if (node.source.type === AST_NODE_TYPES37.Literal && typeof node.source.value === "string") {
|
|
3051
2821
|
checkImportPath(node.source.value, node);
|
|
3052
2822
|
}
|
|
3053
2823
|
},
|
|
3054
2824
|
ExportNamedDeclaration(node) {
|
|
3055
|
-
if (node.source?.type ===
|
|
2825
|
+
if (node.source?.type === AST_NODE_TYPES37.Literal && typeof node.source.value === "string") {
|
|
3056
2826
|
checkImportPath(node.source.value, node);
|
|
3057
2827
|
}
|
|
3058
2828
|
},
|
|
3059
2829
|
ExportAllDeclaration(node) {
|
|
3060
|
-
if (node.source.type ===
|
|
2830
|
+
if (node.source.type === AST_NODE_TYPES37.Literal && typeof node.source.value === "string") {
|
|
3061
2831
|
checkImportPath(node.source.value, node);
|
|
3062
2832
|
}
|
|
3063
2833
|
}
|
|
@@ -3067,8 +2837,8 @@ var noRelativeImports = createRule41({
|
|
|
3067
2837
|
var no_relative_imports_default = noRelativeImports;
|
|
3068
2838
|
|
|
3069
2839
|
// src/rules/no-single-char-variables.ts
|
|
3070
|
-
import { AST_NODE_TYPES as
|
|
3071
|
-
var
|
|
2840
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES38, ESLintUtils as ESLintUtils38 } from "@typescript-eslint/utils";
|
|
2841
|
+
var createRule38 = ESLintUtils38.RuleCreator(
|
|
3072
2842
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3073
2843
|
);
|
|
3074
2844
|
var ALLOWED_IN_FOR_LOOPS = /* @__PURE__ */ new Set(["i", "j", "k", "n"]);
|
|
@@ -3080,7 +2850,7 @@ var isForLoopInit = (node) => {
|
|
|
3080
2850
|
if (!parentNode) {
|
|
3081
2851
|
return false;
|
|
3082
2852
|
}
|
|
3083
|
-
if (parentNode.type ===
|
|
2853
|
+
if (parentNode.type === AST_NODE_TYPES38.ForStatement) {
|
|
3084
2854
|
const { init } = parentNode;
|
|
3085
2855
|
if (init && init === current) {
|
|
3086
2856
|
return true;
|
|
@@ -3099,7 +2869,7 @@ var isAllowedInContext = (name, node) => {
|
|
|
3099
2869
|
}
|
|
3100
2870
|
return false;
|
|
3101
2871
|
};
|
|
3102
|
-
var noSingleCharVariables =
|
|
2872
|
+
var noSingleCharVariables = createRule38({
|
|
3103
2873
|
name: "no-single-char-variables",
|
|
3104
2874
|
meta: {
|
|
3105
2875
|
type: "suggestion",
|
|
@@ -3128,27 +2898,27 @@ var noSingleCharVariables = createRule42({
|
|
|
3128
2898
|
});
|
|
3129
2899
|
};
|
|
3130
2900
|
const checkPattern = (pattern, declarationNode) => {
|
|
3131
|
-
if (pattern.type ===
|
|
2901
|
+
if (pattern.type === AST_NODE_TYPES38.Identifier) {
|
|
3132
2902
|
checkIdentifier(pattern, declarationNode);
|
|
3133
|
-
} else if (pattern.type ===
|
|
2903
|
+
} else if (pattern.type === AST_NODE_TYPES38.ObjectPattern) {
|
|
3134
2904
|
pattern.properties.forEach((prop) => {
|
|
3135
|
-
if (prop.type ===
|
|
2905
|
+
if (prop.type === AST_NODE_TYPES38.Property && prop.value.type === AST_NODE_TYPES38.Identifier) {
|
|
3136
2906
|
checkIdentifier(prop.value, declarationNode);
|
|
3137
|
-
} else if (prop.type ===
|
|
2907
|
+
} else if (prop.type === AST_NODE_TYPES38.RestElement && prop.argument.type === AST_NODE_TYPES38.Identifier) {
|
|
3138
2908
|
checkIdentifier(prop.argument, declarationNode);
|
|
3139
2909
|
}
|
|
3140
2910
|
});
|
|
3141
|
-
} else if (pattern.type ===
|
|
2911
|
+
} else if (pattern.type === AST_NODE_TYPES38.ArrayPattern) {
|
|
3142
2912
|
pattern.elements.forEach((element) => {
|
|
3143
|
-
if (element?.type ===
|
|
2913
|
+
if (element?.type === AST_NODE_TYPES38.Identifier) {
|
|
3144
2914
|
checkIdentifier(element, declarationNode);
|
|
3145
|
-
} else if (element?.type ===
|
|
2915
|
+
} else if (element?.type === AST_NODE_TYPES38.RestElement && element.argument.type === AST_NODE_TYPES38.Identifier) {
|
|
3146
2916
|
checkIdentifier(element.argument, declarationNode);
|
|
3147
2917
|
}
|
|
3148
2918
|
});
|
|
3149
|
-
} else if (pattern.type ===
|
|
2919
|
+
} else if (pattern.type === AST_NODE_TYPES38.AssignmentPattern && pattern.left.type === AST_NODE_TYPES38.Identifier) {
|
|
3150
2920
|
checkIdentifier(pattern.left, declarationNode);
|
|
3151
|
-
} else if (pattern.type ===
|
|
2921
|
+
} else if (pattern.type === AST_NODE_TYPES38.RestElement && pattern.argument.type === AST_NODE_TYPES38.Identifier) {
|
|
3152
2922
|
checkIdentifier(pattern.argument, declarationNode);
|
|
3153
2923
|
}
|
|
3154
2924
|
};
|
|
@@ -3182,11 +2952,11 @@ var noSingleCharVariables = createRule42({
|
|
|
3182
2952
|
var no_single_char_variables_default = noSingleCharVariables;
|
|
3183
2953
|
|
|
3184
2954
|
// src/rules/prefer-async-await.ts
|
|
3185
|
-
import { AST_NODE_TYPES as
|
|
3186
|
-
var
|
|
2955
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES39, ESLintUtils as ESLintUtils39 } from "@typescript-eslint/utils";
|
|
2956
|
+
var createRule39 = ESLintUtils39.RuleCreator(
|
|
3187
2957
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3188
2958
|
);
|
|
3189
|
-
var preferAsyncAwait =
|
|
2959
|
+
var preferAsyncAwait = createRule39({
|
|
3190
2960
|
name: "prefer-async-await",
|
|
3191
2961
|
meta: {
|
|
3192
2962
|
type: "suggestion",
|
|
@@ -3202,7 +2972,7 @@ var preferAsyncAwait = createRule43({
|
|
|
3202
2972
|
create(context) {
|
|
3203
2973
|
return {
|
|
3204
2974
|
CallExpression(node) {
|
|
3205
|
-
if (node.callee.type ===
|
|
2975
|
+
if (node.callee.type === AST_NODE_TYPES39.MemberExpression && node.callee.property.type === AST_NODE_TYPES39.Identifier && node.callee.property.name === "then") {
|
|
3206
2976
|
context.report({
|
|
3207
2977
|
node: node.callee.property,
|
|
3208
2978
|
messageId: "preferAsyncAwait"
|
|
@@ -3215,11 +2985,11 @@ var preferAsyncAwait = createRule43({
|
|
|
3215
2985
|
var prefer_async_await_default = preferAsyncAwait;
|
|
3216
2986
|
|
|
3217
2987
|
// src/rules/prefer-destructuring-params.ts
|
|
3218
|
-
import { AST_NODE_TYPES as
|
|
3219
|
-
var
|
|
2988
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES40, ESLintUtils as ESLintUtils40 } from "@typescript-eslint/utils";
|
|
2989
|
+
var createRule40 = ESLintUtils40.RuleCreator(
|
|
3220
2990
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3221
2991
|
);
|
|
3222
|
-
var preferDestructuringParams =
|
|
2992
|
+
var preferDestructuringParams = createRule40({
|
|
3223
2993
|
name: "prefer-destructuring-params",
|
|
3224
2994
|
meta: {
|
|
3225
2995
|
type: "suggestion",
|
|
@@ -3235,18 +3005,18 @@ var preferDestructuringParams = createRule44({
|
|
|
3235
3005
|
create(context) {
|
|
3236
3006
|
const isCallbackFunction2 = (node) => {
|
|
3237
3007
|
const { parent } = node;
|
|
3238
|
-
return parent?.type ===
|
|
3008
|
+
return parent?.type === AST_NODE_TYPES40.CallExpression;
|
|
3239
3009
|
};
|
|
3240
3010
|
const isDeveloperFunction = (node) => {
|
|
3241
|
-
if (node.type ===
|
|
3011
|
+
if (node.type === AST_NODE_TYPES40.FunctionDeclaration) {
|
|
3242
3012
|
return true;
|
|
3243
3013
|
}
|
|
3244
|
-
if (node.type ===
|
|
3014
|
+
if (node.type === AST_NODE_TYPES40.FunctionExpression || node.type === AST_NODE_TYPES40.ArrowFunctionExpression) {
|
|
3245
3015
|
if (isCallbackFunction2(node)) {
|
|
3246
3016
|
return false;
|
|
3247
3017
|
}
|
|
3248
3018
|
const { parent } = node;
|
|
3249
|
-
return parent?.type ===
|
|
3019
|
+
return parent?.type === AST_NODE_TYPES40.VariableDeclarator || parent?.type === AST_NODE_TYPES40.AssignmentExpression || parent?.type === AST_NODE_TYPES40.Property || parent?.type === AST_NODE_TYPES40.MethodDefinition;
|
|
3250
3020
|
}
|
|
3251
3021
|
return false;
|
|
3252
3022
|
};
|
|
@@ -3258,7 +3028,7 @@ var preferDestructuringParams = createRule44({
|
|
|
3258
3028
|
if (!isDeveloperFunction(node)) {
|
|
3259
3029
|
return;
|
|
3260
3030
|
}
|
|
3261
|
-
if (node.type ===
|
|
3031
|
+
if (node.type === AST_NODE_TYPES40.FunctionDeclaration && node.id) {
|
|
3262
3032
|
const functionName = node.id.name;
|
|
3263
3033
|
if (functionName.startsWith("_") || functionName.includes("$") || /^[A-Z][a-zA-Z]*$/.test(functionName)) {
|
|
3264
3034
|
return;
|
|
@@ -3268,7 +3038,7 @@ var preferDestructuringParams = createRule44({
|
|
|
3268
3038
|
return;
|
|
3269
3039
|
}
|
|
3270
3040
|
const hasNonDestructuredParams = node.params.some(
|
|
3271
|
-
(param) => param.type !==
|
|
3041
|
+
(param) => param.type !== AST_NODE_TYPES40.ObjectPattern && param.type !== AST_NODE_TYPES40.RestElement
|
|
3272
3042
|
);
|
|
3273
3043
|
if (hasNonDestructuredParams) {
|
|
3274
3044
|
context.report({
|
|
@@ -3287,8 +3057,8 @@ var preferDestructuringParams = createRule44({
|
|
|
3287
3057
|
var prefer_destructuring_params_default = preferDestructuringParams;
|
|
3288
3058
|
|
|
3289
3059
|
// src/rules/prefer-function-declaration.ts
|
|
3290
|
-
import { AST_NODE_TYPES as
|
|
3291
|
-
var
|
|
3060
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES41, ESLintUtils as ESLintUtils41 } from "@typescript-eslint/utils";
|
|
3061
|
+
var createRule41 = ESLintUtils41.RuleCreator(
|
|
3292
3062
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3293
3063
|
);
|
|
3294
3064
|
var isTsFile = (filename) => filename.endsWith(".ts") && !filename.endsWith(".d.ts");
|
|
@@ -3297,33 +3067,33 @@ var isCallbackContext = (node) => {
|
|
|
3297
3067
|
if (!parent) {
|
|
3298
3068
|
return false;
|
|
3299
3069
|
}
|
|
3300
|
-
if (parent.type ===
|
|
3070
|
+
if (parent.type === AST_NODE_TYPES41.CallExpression && parent.arguments.includes(node)) {
|
|
3301
3071
|
return true;
|
|
3302
3072
|
}
|
|
3303
|
-
if (parent.type ===
|
|
3073
|
+
if (parent.type === AST_NODE_TYPES41.NewExpression && parent.arguments.includes(node)) {
|
|
3304
3074
|
return true;
|
|
3305
3075
|
}
|
|
3306
|
-
if (parent.type ===
|
|
3076
|
+
if (parent.type === AST_NODE_TYPES41.ReturnStatement) {
|
|
3307
3077
|
return true;
|
|
3308
3078
|
}
|
|
3309
|
-
if (parent.type ===
|
|
3079
|
+
if (parent.type === AST_NODE_TYPES41.Property) {
|
|
3310
3080
|
return true;
|
|
3311
3081
|
}
|
|
3312
|
-
if (parent.type ===
|
|
3082
|
+
if (parent.type === AST_NODE_TYPES41.ArrayExpression) {
|
|
3313
3083
|
return true;
|
|
3314
3084
|
}
|
|
3315
|
-
if (parent.type ===
|
|
3085
|
+
if (parent.type === AST_NODE_TYPES41.ConditionalExpression) {
|
|
3316
3086
|
return true;
|
|
3317
3087
|
}
|
|
3318
|
-
if (parent.type ===
|
|
3088
|
+
if (parent.type === AST_NODE_TYPES41.LogicalExpression) {
|
|
3319
3089
|
return true;
|
|
3320
3090
|
}
|
|
3321
|
-
if (parent.type ===
|
|
3091
|
+
if (parent.type === AST_NODE_TYPES41.AssignmentExpression && parent.left !== node) {
|
|
3322
3092
|
return true;
|
|
3323
3093
|
}
|
|
3324
3094
|
return false;
|
|
3325
3095
|
};
|
|
3326
|
-
var preferFunctionDeclaration =
|
|
3096
|
+
var preferFunctionDeclaration = createRule41({
|
|
3327
3097
|
name: "prefer-function-declaration",
|
|
3328
3098
|
meta: {
|
|
3329
3099
|
type: "suggestion",
|
|
@@ -3344,14 +3114,14 @@ var preferFunctionDeclaration = createRule45({
|
|
|
3344
3114
|
}
|
|
3345
3115
|
return {
|
|
3346
3116
|
VariableDeclarator(node) {
|
|
3347
|
-
if (node.id.type !==
|
|
3117
|
+
if (node.id.type !== AST_NODE_TYPES41.Identifier) {
|
|
3348
3118
|
return;
|
|
3349
3119
|
}
|
|
3350
3120
|
const { init } = node;
|
|
3351
3121
|
if (!init) {
|
|
3352
3122
|
return;
|
|
3353
3123
|
}
|
|
3354
|
-
if (init.type ===
|
|
3124
|
+
if (init.type === AST_NODE_TYPES41.ArrowFunctionExpression) {
|
|
3355
3125
|
if (isCallbackContext(init)) {
|
|
3356
3126
|
return;
|
|
3357
3127
|
}
|
|
@@ -3361,7 +3131,7 @@ var preferFunctionDeclaration = createRule45({
|
|
|
3361
3131
|
data: { name: node.id.name }
|
|
3362
3132
|
});
|
|
3363
3133
|
}
|
|
3364
|
-
if (init.type ===
|
|
3134
|
+
if (init.type === AST_NODE_TYPES41.FunctionExpression) {
|
|
3365
3135
|
if (isCallbackContext(init)) {
|
|
3366
3136
|
return;
|
|
3367
3137
|
}
|
|
@@ -3378,11 +3148,11 @@ var preferFunctionDeclaration = createRule45({
|
|
|
3378
3148
|
var prefer_function_declaration_default = preferFunctionDeclaration;
|
|
3379
3149
|
|
|
3380
3150
|
// src/rules/prefer-guard-clause.ts
|
|
3381
|
-
import { AST_NODE_TYPES as
|
|
3382
|
-
var
|
|
3151
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES42, ESLintUtils as ESLintUtils42 } from "@typescript-eslint/utils";
|
|
3152
|
+
var createRule42 = ESLintUtils42.RuleCreator(
|
|
3383
3153
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3384
3154
|
);
|
|
3385
|
-
var preferGuardClause =
|
|
3155
|
+
var preferGuardClause = createRule42({
|
|
3386
3156
|
name: "prefer-guard-clause",
|
|
3387
3157
|
meta: {
|
|
3388
3158
|
type: "suggestion",
|
|
@@ -3399,8 +3169,8 @@ var preferGuardClause = createRule46({
|
|
|
3399
3169
|
return {
|
|
3400
3170
|
IfStatement(node) {
|
|
3401
3171
|
const { consequent } = node;
|
|
3402
|
-
if (consequent.type ===
|
|
3403
|
-
const hasNestedIf = consequent.body.some((statement) => statement.type ===
|
|
3172
|
+
if (consequent.type === AST_NODE_TYPES42.BlockStatement) {
|
|
3173
|
+
const hasNestedIf = consequent.body.some((statement) => statement.type === AST_NODE_TYPES42.IfStatement);
|
|
3404
3174
|
if (hasNestedIf && consequent.body.length === 1) {
|
|
3405
3175
|
context.report({
|
|
3406
3176
|
node,
|
|
@@ -3408,7 +3178,7 @@ var preferGuardClause = createRule46({
|
|
|
3408
3178
|
});
|
|
3409
3179
|
}
|
|
3410
3180
|
}
|
|
3411
|
-
if (consequent.type ===
|
|
3181
|
+
if (consequent.type === AST_NODE_TYPES42.IfStatement) {
|
|
3412
3182
|
context.report({
|
|
3413
3183
|
node,
|
|
3414
3184
|
messageId: "preferGuardClause"
|
|
@@ -3421,11 +3191,11 @@ var preferGuardClause = createRule46({
|
|
|
3421
3191
|
var prefer_guard_clause_default = preferGuardClause;
|
|
3422
3192
|
|
|
3423
3193
|
// src/rules/prefer-import-type.ts
|
|
3424
|
-
import { AST_NODE_TYPES as
|
|
3425
|
-
var
|
|
3194
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES43, ESLintUtils as ESLintUtils43 } from "@typescript-eslint/utils";
|
|
3195
|
+
var createRule43 = ESLintUtils43.RuleCreator(
|
|
3426
3196
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3427
3197
|
);
|
|
3428
|
-
var preferImportType =
|
|
3198
|
+
var preferImportType = createRule43({
|
|
3429
3199
|
name: "prefer-import-type",
|
|
3430
3200
|
meta: {
|
|
3431
3201
|
type: "suggestion",
|
|
@@ -3444,22 +3214,22 @@ var preferImportType = createRule47({
|
|
|
3444
3214
|
let current = node;
|
|
3445
3215
|
while (current) {
|
|
3446
3216
|
switch (current.type) {
|
|
3447
|
-
case
|
|
3448
|
-
case
|
|
3449
|
-
case
|
|
3450
|
-
case
|
|
3451
|
-
case
|
|
3452
|
-
case
|
|
3453
|
-
case
|
|
3454
|
-
case
|
|
3455
|
-
case
|
|
3456
|
-
case
|
|
3457
|
-
case
|
|
3458
|
-
case
|
|
3459
|
-
case
|
|
3217
|
+
case AST_NODE_TYPES43.TSTypeReference:
|
|
3218
|
+
case AST_NODE_TYPES43.TSTypeAnnotation:
|
|
3219
|
+
case AST_NODE_TYPES43.TSTypeParameterInstantiation:
|
|
3220
|
+
case AST_NODE_TYPES43.TSInterfaceHeritage:
|
|
3221
|
+
case AST_NODE_TYPES43.TSClassImplements:
|
|
3222
|
+
case AST_NODE_TYPES43.TSTypeQuery:
|
|
3223
|
+
case AST_NODE_TYPES43.TSTypeAssertion:
|
|
3224
|
+
case AST_NODE_TYPES43.TSAsExpression:
|
|
3225
|
+
case AST_NODE_TYPES43.TSSatisfiesExpression:
|
|
3226
|
+
case AST_NODE_TYPES43.TSTypeAliasDeclaration:
|
|
3227
|
+
case AST_NODE_TYPES43.TSInterfaceDeclaration:
|
|
3228
|
+
case AST_NODE_TYPES43.TSTypeParameter:
|
|
3229
|
+
case AST_NODE_TYPES43.TSQualifiedName:
|
|
3460
3230
|
return true;
|
|
3461
|
-
case
|
|
3462
|
-
case
|
|
3231
|
+
case AST_NODE_TYPES43.MemberExpression:
|
|
3232
|
+
case AST_NODE_TYPES43.Identifier:
|
|
3463
3233
|
current = current.parent;
|
|
3464
3234
|
break;
|
|
3465
3235
|
default:
|
|
@@ -3489,27 +3259,27 @@ var preferImportType = createRule47({
|
|
|
3489
3259
|
return false;
|
|
3490
3260
|
}
|
|
3491
3261
|
switch (parent.type) {
|
|
3492
|
-
case
|
|
3493
|
-
case
|
|
3494
|
-
case
|
|
3495
|
-
case
|
|
3496
|
-
case
|
|
3497
|
-
case
|
|
3498
|
-
case
|
|
3499
|
-
case
|
|
3500
|
-
case
|
|
3501
|
-
case
|
|
3502
|
-
case
|
|
3503
|
-
case
|
|
3504
|
-
case
|
|
3505
|
-
case
|
|
3506
|
-
case
|
|
3507
|
-
case
|
|
3508
|
-
case
|
|
3509
|
-
case
|
|
3510
|
-
case
|
|
3511
|
-
case
|
|
3512
|
-
case
|
|
3262
|
+
case AST_NODE_TYPES43.CallExpression:
|
|
3263
|
+
case AST_NODE_TYPES43.NewExpression:
|
|
3264
|
+
case AST_NODE_TYPES43.JSXOpeningElement:
|
|
3265
|
+
case AST_NODE_TYPES43.JSXClosingElement:
|
|
3266
|
+
case AST_NODE_TYPES43.MemberExpression:
|
|
3267
|
+
case AST_NODE_TYPES43.VariableDeclarator:
|
|
3268
|
+
case AST_NODE_TYPES43.TaggedTemplateExpression:
|
|
3269
|
+
case AST_NODE_TYPES43.SpreadElement:
|
|
3270
|
+
case AST_NODE_TYPES43.ExportSpecifier:
|
|
3271
|
+
case AST_NODE_TYPES43.ArrayExpression:
|
|
3272
|
+
case AST_NODE_TYPES43.ObjectExpression:
|
|
3273
|
+
case AST_NODE_TYPES43.BinaryExpression:
|
|
3274
|
+
case AST_NODE_TYPES43.LogicalExpression:
|
|
3275
|
+
case AST_NODE_TYPES43.UnaryExpression:
|
|
3276
|
+
case AST_NODE_TYPES43.ReturnStatement:
|
|
3277
|
+
case AST_NODE_TYPES43.ArrowFunctionExpression:
|
|
3278
|
+
case AST_NODE_TYPES43.ConditionalExpression:
|
|
3279
|
+
case AST_NODE_TYPES43.AwaitExpression:
|
|
3280
|
+
case AST_NODE_TYPES43.YieldExpression:
|
|
3281
|
+
case AST_NODE_TYPES43.Property:
|
|
3282
|
+
case AST_NODE_TYPES43.JSXExpressionContainer:
|
|
3513
3283
|
return true;
|
|
3514
3284
|
default:
|
|
3515
3285
|
return false;
|
|
@@ -3520,6 +3290,12 @@ var preferImportType = createRule47({
|
|
|
3520
3290
|
if (node.importKind === "type") {
|
|
3521
3291
|
return;
|
|
3522
3292
|
}
|
|
3293
|
+
const hasInlineTypeSpecifier = node.specifiers.some(
|
|
3294
|
+
(specifier) => specifier.type === AST_NODE_TYPES43.ImportSpecifier && specifier.importKind === "type"
|
|
3295
|
+
);
|
|
3296
|
+
if (hasInlineTypeSpecifier) {
|
|
3297
|
+
return;
|
|
3298
|
+
}
|
|
3523
3299
|
if (context.filename.includes(".test.") || context.filename.includes(".spec.") || context.filename.includes("__tests__")) {
|
|
3524
3300
|
return;
|
|
3525
3301
|
}
|
|
@@ -3533,13 +3309,13 @@ var preferImportType = createRule47({
|
|
|
3533
3309
|
}
|
|
3534
3310
|
const scope = context.sourceCode.getScope(node);
|
|
3535
3311
|
const isTypeOnlyImport2 = node.specifiers.every((specifier) => {
|
|
3536
|
-
if (specifier.type ===
|
|
3312
|
+
if (specifier.type === AST_NODE_TYPES43.ImportDefaultSpecifier) {
|
|
3537
3313
|
return false;
|
|
3538
3314
|
}
|
|
3539
|
-
if (specifier.type ===
|
|
3315
|
+
if (specifier.type === AST_NODE_TYPES43.ImportNamespaceSpecifier) {
|
|
3540
3316
|
return false;
|
|
3541
3317
|
}
|
|
3542
|
-
if (specifier.type ===
|
|
3318
|
+
if (specifier.type === AST_NODE_TYPES43.ImportSpecifier) {
|
|
3543
3319
|
const localName = specifier.local.name;
|
|
3544
3320
|
return !isUsedAsValue(localName, scope);
|
|
3545
3321
|
}
|
|
@@ -3565,19 +3341,19 @@ var preferImportType = createRule47({
|
|
|
3565
3341
|
var prefer_import_type_default = preferImportType;
|
|
3566
3342
|
|
|
3567
3343
|
// src/rules/prefer-inline-literal-union.ts
|
|
3568
|
-
import { AST_NODE_TYPES as
|
|
3569
|
-
var
|
|
3344
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES44, ESLintUtils as ESLintUtils44 } from "@typescript-eslint/utils";
|
|
3345
|
+
var createRule44 = ESLintUtils44.RuleCreator(
|
|
3570
3346
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3571
3347
|
);
|
|
3572
3348
|
function isLiteralUnionType(node) {
|
|
3573
|
-
if (node.type !==
|
|
3349
|
+
if (node.type !== AST_NODE_TYPES44.TSUnionType) {
|
|
3574
3350
|
return false;
|
|
3575
3351
|
}
|
|
3576
3352
|
return node.types.every(
|
|
3577
|
-
(member) => member.type ===
|
|
3353
|
+
(member) => member.type === AST_NODE_TYPES44.TSLiteralType || member.type === AST_NODE_TYPES44.TSNullKeyword || member.type === AST_NODE_TYPES44.TSUndefinedKeyword
|
|
3578
3354
|
);
|
|
3579
3355
|
}
|
|
3580
|
-
var preferInlineLiteralUnion =
|
|
3356
|
+
var preferInlineLiteralUnion = createRule44({
|
|
3581
3357
|
name: "prefer-inline-literal-union",
|
|
3582
3358
|
meta: {
|
|
3583
3359
|
type: "suggestion",
|
|
@@ -3604,10 +3380,10 @@ var preferInlineLiteralUnion = createRule48({
|
|
|
3604
3380
|
return;
|
|
3605
3381
|
}
|
|
3606
3382
|
const { typeAnnotation } = node.typeAnnotation;
|
|
3607
|
-
if (typeAnnotation.type !==
|
|
3383
|
+
if (typeAnnotation.type !== AST_NODE_TYPES44.TSTypeReference) {
|
|
3608
3384
|
return;
|
|
3609
3385
|
}
|
|
3610
|
-
if (typeAnnotation.typeName.type !==
|
|
3386
|
+
if (typeAnnotation.typeName.type !== AST_NODE_TYPES44.Identifier) {
|
|
3611
3387
|
return;
|
|
3612
3388
|
}
|
|
3613
3389
|
const aliasName = typeAnnotation.typeName.name;
|
|
@@ -3631,12 +3407,12 @@ var preferInlineLiteralUnion = createRule48({
|
|
|
3631
3407
|
var prefer_inline_literal_union_default = preferInlineLiteralUnion;
|
|
3632
3408
|
|
|
3633
3409
|
// src/rules/prefer-inline-type-export.ts
|
|
3634
|
-
import { AST_NODE_TYPES as
|
|
3635
|
-
var
|
|
3410
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES45, ESLintUtils as ESLintUtils45 } from "@typescript-eslint/utils";
|
|
3411
|
+
var createRule45 = ESLintUtils45.RuleCreator(
|
|
3636
3412
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3637
3413
|
);
|
|
3638
|
-
var isTypeDeclaration = (node) => node.type ===
|
|
3639
|
-
var preferInlineTypeExport =
|
|
3414
|
+
var isTypeDeclaration = (node) => node.type === AST_NODE_TYPES45.TSInterfaceDeclaration || node.type === AST_NODE_TYPES45.TSTypeAliasDeclaration;
|
|
3415
|
+
var preferInlineTypeExport = createRule45({
|
|
3640
3416
|
name: "prefer-inline-type-export",
|
|
3641
3417
|
meta: {
|
|
3642
3418
|
type: "suggestion",
|
|
@@ -3653,12 +3429,12 @@ var preferInlineTypeExport = createRule49({
|
|
|
3653
3429
|
create(context) {
|
|
3654
3430
|
const typeDeclarations = /* @__PURE__ */ new Map();
|
|
3655
3431
|
function collectDeclaration(node) {
|
|
3656
|
-
if (node.parent.type !==
|
|
3432
|
+
if (node.parent.type !== AST_NODE_TYPES45.ExportNamedDeclaration) {
|
|
3657
3433
|
typeDeclarations.set(node.id.name, node);
|
|
3658
3434
|
}
|
|
3659
3435
|
}
|
|
3660
3436
|
function reportSpecifier(specifier, statement, declarationNode) {
|
|
3661
|
-
if (specifier.local.type !==
|
|
3437
|
+
if (specifier.local.type !== AST_NODE_TYPES45.Identifier) {
|
|
3662
3438
|
return;
|
|
3663
3439
|
}
|
|
3664
3440
|
const { name } = specifier.local;
|
|
@@ -3691,16 +3467,16 @@ var preferInlineTypeExport = createRule49({
|
|
|
3691
3467
|
return {
|
|
3692
3468
|
Program(node) {
|
|
3693
3469
|
node.body.forEach((statement) => {
|
|
3694
|
-
if (statement.type ===
|
|
3470
|
+
if (statement.type === AST_NODE_TYPES45.TSInterfaceDeclaration || statement.type === AST_NODE_TYPES45.TSTypeAliasDeclaration) {
|
|
3695
3471
|
collectDeclaration(statement);
|
|
3696
3472
|
}
|
|
3697
3473
|
});
|
|
3698
3474
|
node.body.forEach((statement) => {
|
|
3699
|
-
if (statement.type !==
|
|
3475
|
+
if (statement.type !== AST_NODE_TYPES45.ExportNamedDeclaration || statement.declaration !== null) {
|
|
3700
3476
|
return;
|
|
3701
3477
|
}
|
|
3702
3478
|
statement.specifiers.forEach((specifier) => {
|
|
3703
|
-
if (specifier.local.type !==
|
|
3479
|
+
if (specifier.local.type !== AST_NODE_TYPES45.Identifier) {
|
|
3704
3480
|
return;
|
|
3705
3481
|
}
|
|
3706
3482
|
const declarationNode = typeDeclarations.get(specifier.local.name);
|
|
@@ -3716,12 +3492,69 @@ var preferInlineTypeExport = createRule49({
|
|
|
3716
3492
|
});
|
|
3717
3493
|
var prefer_inline_type_export_default = preferInlineTypeExport;
|
|
3718
3494
|
|
|
3495
|
+
// src/rules/prefer-interface-for-component-props.ts
|
|
3496
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES46, ESLintUtils as ESLintUtils46 } from "@typescript-eslint/utils";
|
|
3497
|
+
var createRule46 = ESLintUtils46.RuleCreator(
|
|
3498
|
+
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3499
|
+
);
|
|
3500
|
+
var preferInterfaceForComponentProps = createRule46({
|
|
3501
|
+
name: "prefer-interface-for-component-props",
|
|
3502
|
+
meta: {
|
|
3503
|
+
type: "suggestion",
|
|
3504
|
+
docs: {
|
|
3505
|
+
description: "Enforce 'interface' over 'type' alias for component prop declarations in component files (*.tsx, *.jsx)"
|
|
3506
|
+
},
|
|
3507
|
+
fixable: "code",
|
|
3508
|
+
schema: [],
|
|
3509
|
+
messages: {
|
|
3510
|
+
preferInterface: "Component props '{{ name }}' should use 'interface' instead of 'type' alias."
|
|
3511
|
+
}
|
|
3512
|
+
},
|
|
3513
|
+
defaultOptions: [],
|
|
3514
|
+
create(context) {
|
|
3515
|
+
if (!isJsxFile(context.filename)) {
|
|
3516
|
+
return {};
|
|
3517
|
+
}
|
|
3518
|
+
return {
|
|
3519
|
+
TSTypeAliasDeclaration(node) {
|
|
3520
|
+
if (node.id.type !== AST_NODE_TYPES46.Identifier) {
|
|
3521
|
+
return;
|
|
3522
|
+
}
|
|
3523
|
+
if (!node.id.name.endsWith("Props")) {
|
|
3524
|
+
return;
|
|
3525
|
+
}
|
|
3526
|
+
if (node.typeAnnotation.type !== AST_NODE_TYPES46.TSTypeLiteral) {
|
|
3527
|
+
return;
|
|
3528
|
+
}
|
|
3529
|
+
const { name } = node.id;
|
|
3530
|
+
context.report({
|
|
3531
|
+
node: node.id,
|
|
3532
|
+
messageId: "preferInterface",
|
|
3533
|
+
data: { name },
|
|
3534
|
+
fix(fixer) {
|
|
3535
|
+
const { sourceCode } = context;
|
|
3536
|
+
const typeText = sourceCode.getText(node.typeAnnotation);
|
|
3537
|
+
const typeParamsText = node.typeParameters ? sourceCode.getText(node.typeParameters) : "";
|
|
3538
|
+
const newText = `interface ${name}${typeParamsText} ${typeText}`;
|
|
3539
|
+
const tokenAfter = sourceCode.getTokenAfter(node);
|
|
3540
|
+
if (tokenAfter && tokenAfter.value === ";") {
|
|
3541
|
+
return fixer.replaceTextRange([node.range[0], tokenAfter.range[1]], newText);
|
|
3542
|
+
}
|
|
3543
|
+
return fixer.replaceText(node, newText);
|
|
3544
|
+
}
|
|
3545
|
+
});
|
|
3546
|
+
}
|
|
3547
|
+
};
|
|
3548
|
+
}
|
|
3549
|
+
});
|
|
3550
|
+
var prefer_interface_for_component_props_default = preferInterfaceForComponentProps;
|
|
3551
|
+
|
|
3719
3552
|
// src/rules/prefer-interface-over-inline-types.ts
|
|
3720
|
-
import { AST_NODE_TYPES as
|
|
3721
|
-
var
|
|
3553
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES47, ESLintUtils as ESLintUtils47 } from "@typescript-eslint/utils";
|
|
3554
|
+
var createRule47 = ESLintUtils47.RuleCreator(
|
|
3722
3555
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3723
3556
|
);
|
|
3724
|
-
var preferInterfaceOverInlineTypes =
|
|
3557
|
+
var preferInterfaceOverInlineTypes = createRule47({
|
|
3725
3558
|
name: "prefer-interface-over-inline-types",
|
|
3726
3559
|
meta: {
|
|
3727
3560
|
type: "suggestion",
|
|
@@ -3737,54 +3570,54 @@ var preferInterfaceOverInlineTypes = createRule50({
|
|
|
3737
3570
|
defaultOptions: [],
|
|
3738
3571
|
create(context) {
|
|
3739
3572
|
function hasJSXInConditional(node) {
|
|
3740
|
-
return node.consequent.type ===
|
|
3573
|
+
return node.consequent.type === AST_NODE_TYPES47.JSXElement || node.consequent.type === AST_NODE_TYPES47.JSXFragment || node.alternate.type === AST_NODE_TYPES47.JSXElement || node.alternate.type === AST_NODE_TYPES47.JSXFragment;
|
|
3741
3574
|
}
|
|
3742
3575
|
function hasJSXInLogical(node) {
|
|
3743
|
-
return node.right.type ===
|
|
3576
|
+
return node.right.type === AST_NODE_TYPES47.JSXElement || node.right.type === AST_NODE_TYPES47.JSXFragment;
|
|
3744
3577
|
}
|
|
3745
3578
|
function hasJSXReturn(block) {
|
|
3746
3579
|
return block.body.some((stmt) => {
|
|
3747
|
-
if (stmt.type ===
|
|
3748
|
-
return stmt.argument.type ===
|
|
3580
|
+
if (stmt.type === AST_NODE_TYPES47.ReturnStatement && stmt.argument) {
|
|
3581
|
+
return stmt.argument.type === AST_NODE_TYPES47.JSXElement || stmt.argument.type === AST_NODE_TYPES47.JSXFragment || stmt.argument.type === AST_NODE_TYPES47.ConditionalExpression && hasJSXInConditional(stmt.argument) || stmt.argument.type === AST_NODE_TYPES47.LogicalExpression && hasJSXInLogical(stmt.argument);
|
|
3749
3582
|
}
|
|
3750
3583
|
return false;
|
|
3751
3584
|
});
|
|
3752
3585
|
}
|
|
3753
3586
|
function isReactComponent2(node) {
|
|
3754
|
-
if (node.type ===
|
|
3755
|
-
if (node.body.type ===
|
|
3587
|
+
if (node.type === AST_NODE_TYPES47.ArrowFunctionExpression) {
|
|
3588
|
+
if (node.body.type === AST_NODE_TYPES47.JSXElement || node.body.type === AST_NODE_TYPES47.JSXFragment) {
|
|
3756
3589
|
return true;
|
|
3757
3590
|
}
|
|
3758
|
-
if (node.body.type ===
|
|
3591
|
+
if (node.body.type === AST_NODE_TYPES47.BlockStatement) {
|
|
3759
3592
|
return hasJSXReturn(node.body);
|
|
3760
3593
|
}
|
|
3761
|
-
} else if (node.type ===
|
|
3762
|
-
if (node.body && node.body.type ===
|
|
3594
|
+
} else if (node.type === AST_NODE_TYPES47.FunctionExpression || node.type === AST_NODE_TYPES47.FunctionDeclaration) {
|
|
3595
|
+
if (node.body && node.body.type === AST_NODE_TYPES47.BlockStatement) {
|
|
3763
3596
|
return hasJSXReturn(node.body);
|
|
3764
3597
|
}
|
|
3765
3598
|
}
|
|
3766
3599
|
return false;
|
|
3767
3600
|
}
|
|
3768
3601
|
function isInlineTypeAnnotation(node) {
|
|
3769
|
-
if (node.type ===
|
|
3602
|
+
if (node.type === AST_NODE_TYPES47.TSTypeLiteral) {
|
|
3770
3603
|
return true;
|
|
3771
3604
|
}
|
|
3772
|
-
if (node.type ===
|
|
3773
|
-
return node.typeArguments.params.some((param) => param.type ===
|
|
3605
|
+
if (node.type === AST_NODE_TYPES47.TSTypeReference && node.typeArguments) {
|
|
3606
|
+
return node.typeArguments.params.some((param) => param.type === AST_NODE_TYPES47.TSTypeLiteral);
|
|
3774
3607
|
}
|
|
3775
|
-
if (node.type ===
|
|
3608
|
+
if (node.type === AST_NODE_TYPES47.TSUnionType) {
|
|
3776
3609
|
return node.types.some((type) => isInlineTypeAnnotation(type));
|
|
3777
3610
|
}
|
|
3778
3611
|
return false;
|
|
3779
3612
|
}
|
|
3780
3613
|
function hasInlineObjectType(node) {
|
|
3781
|
-
if (node.type ===
|
|
3614
|
+
if (node.type === AST_NODE_TYPES47.TSTypeLiteral) {
|
|
3782
3615
|
return true;
|
|
3783
3616
|
}
|
|
3784
|
-
if (node.type ===
|
|
3785
|
-
return node.typeArguments.params.some((param) => param.type ===
|
|
3617
|
+
if (node.type === AST_NODE_TYPES47.TSTypeReference && node.typeArguments) {
|
|
3618
|
+
return node.typeArguments.params.some((param) => param.type === AST_NODE_TYPES47.TSTypeLiteral);
|
|
3786
3619
|
}
|
|
3787
|
-
if (node.type ===
|
|
3620
|
+
if (node.type === AST_NODE_TYPES47.TSUnionType) {
|
|
3788
3621
|
return node.types.some((type) => hasInlineObjectType(type));
|
|
3789
3622
|
}
|
|
3790
3623
|
return false;
|
|
@@ -3797,7 +3630,7 @@ var preferInterfaceOverInlineTypes = createRule50({
|
|
|
3797
3630
|
return;
|
|
3798
3631
|
}
|
|
3799
3632
|
const param = node.params[0];
|
|
3800
|
-
if (param.type ===
|
|
3633
|
+
if (param.type === AST_NODE_TYPES47.Identifier && param.typeAnnotation) {
|
|
3801
3634
|
const { typeAnnotation } = param.typeAnnotation;
|
|
3802
3635
|
if (isInlineTypeAnnotation(typeAnnotation) && hasInlineObjectType(typeAnnotation)) {
|
|
3803
3636
|
context.report({
|
|
@@ -3817,11 +3650,11 @@ var preferInterfaceOverInlineTypes = createRule50({
|
|
|
3817
3650
|
var prefer_interface_over_inline_types_default = preferInterfaceOverInlineTypes;
|
|
3818
3651
|
|
|
3819
3652
|
// src/rules/prefer-jsx-template-literals.ts
|
|
3820
|
-
import { AST_NODE_TYPES as
|
|
3821
|
-
var
|
|
3653
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES48, ESLintUtils as ESLintUtils48 } from "@typescript-eslint/utils";
|
|
3654
|
+
var createRule48 = ESLintUtils48.RuleCreator(
|
|
3822
3655
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3823
3656
|
);
|
|
3824
|
-
var preferJSXTemplateLiterals =
|
|
3657
|
+
var preferJSXTemplateLiterals = createRule48({
|
|
3825
3658
|
name: "prefer-jsx-template-literals",
|
|
3826
3659
|
meta: {
|
|
3827
3660
|
type: "suggestion",
|
|
@@ -3890,9 +3723,9 @@ var preferJSXTemplateLiterals = createRule51({
|
|
|
3890
3723
|
if (!child || !nextChild) {
|
|
3891
3724
|
return;
|
|
3892
3725
|
}
|
|
3893
|
-
if (child.type ===
|
|
3726
|
+
if (child.type === AST_NODE_TYPES48.JSXText && nextChild.type === AST_NODE_TYPES48.JSXExpressionContainer) {
|
|
3894
3727
|
handleTextBeforeExpression(child, nextChild);
|
|
3895
|
-
} else if (child.type ===
|
|
3728
|
+
} else if (child.type === AST_NODE_TYPES48.JSXExpressionContainer && nextChild.type === AST_NODE_TYPES48.JSXText) {
|
|
3896
3729
|
handleExpressionBeforeText(child, nextChild);
|
|
3897
3730
|
}
|
|
3898
3731
|
}
|
|
@@ -3905,11 +3738,32 @@ var preferJSXTemplateLiterals = createRule51({
|
|
|
3905
3738
|
var prefer_jsx_template_literals_default = preferJSXTemplateLiterals;
|
|
3906
3739
|
|
|
3907
3740
|
// src/rules/prefer-named-param-types.ts
|
|
3908
|
-
import { AST_NODE_TYPES as
|
|
3909
|
-
var
|
|
3741
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES49, ESLintUtils as ESLintUtils49 } from "@typescript-eslint/utils";
|
|
3742
|
+
var createRule49 = ESLintUtils49.RuleCreator(
|
|
3910
3743
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3911
3744
|
);
|
|
3912
|
-
var
|
|
3745
|
+
var returnsJsx2 = (node) => {
|
|
3746
|
+
if (node.type === AST_NODE_TYPES49.JSXElement || node.type === AST_NODE_TYPES49.JSXFragment) {
|
|
3747
|
+
return true;
|
|
3748
|
+
}
|
|
3749
|
+
if (node.type === AST_NODE_TYPES49.ConditionalExpression) {
|
|
3750
|
+
return returnsJsx2(node.consequent) || returnsJsx2(node.alternate);
|
|
3751
|
+
}
|
|
3752
|
+
if (node.type === AST_NODE_TYPES49.LogicalExpression) {
|
|
3753
|
+
return returnsJsx2(node.left) || returnsJsx2(node.right);
|
|
3754
|
+
}
|
|
3755
|
+
return false;
|
|
3756
|
+
};
|
|
3757
|
+
var bodyReturnsJsx2 = (body) => {
|
|
3758
|
+
if (body.type !== AST_NODE_TYPES49.BlockStatement) {
|
|
3759
|
+
return returnsJsx2(body);
|
|
3760
|
+
}
|
|
3761
|
+
return body.body.some(
|
|
3762
|
+
(stmt) => stmt.type === AST_NODE_TYPES49.ReturnStatement && stmt.argument !== null && returnsJsx2(stmt.argument)
|
|
3763
|
+
);
|
|
3764
|
+
};
|
|
3765
|
+
var isReactComponentFunction = (node) => bodyReturnsJsx2(node.body);
|
|
3766
|
+
var preferNamedParamTypes = createRule49({
|
|
3913
3767
|
name: "prefer-named-param-types",
|
|
3914
3768
|
meta: {
|
|
3915
3769
|
type: "suggestion",
|
|
@@ -3924,16 +3778,16 @@ var preferNamedParamTypes = createRule52({
|
|
|
3924
3778
|
defaultOptions: [],
|
|
3925
3779
|
create(context) {
|
|
3926
3780
|
function hasInlineObjectType(param) {
|
|
3927
|
-
if (param.type ===
|
|
3781
|
+
if (param.type === AST_NODE_TYPES49.AssignmentPattern) {
|
|
3928
3782
|
return hasInlineObjectType(param.left);
|
|
3929
3783
|
}
|
|
3930
|
-
if (param.type ===
|
|
3931
|
-
if (param.typeAnnotation?.typeAnnotation.type ===
|
|
3784
|
+
if (param.type === AST_NODE_TYPES49.ObjectPattern) {
|
|
3785
|
+
if (param.typeAnnotation?.typeAnnotation.type === AST_NODE_TYPES49.TSTypeLiteral) {
|
|
3932
3786
|
return true;
|
|
3933
3787
|
}
|
|
3934
3788
|
}
|
|
3935
|
-
if (param.type ===
|
|
3936
|
-
if (param.typeAnnotation?.typeAnnotation.type ===
|
|
3789
|
+
if (param.type === AST_NODE_TYPES49.Identifier) {
|
|
3790
|
+
if (param.typeAnnotation?.typeAnnotation.type === AST_NODE_TYPES49.TSTypeLiteral) {
|
|
3937
3791
|
return true;
|
|
3938
3792
|
}
|
|
3939
3793
|
}
|
|
@@ -3946,6 +3800,9 @@ var preferNamedParamTypes = createRule52({
|
|
|
3946
3800
|
} else if ("value" in node && node.value) {
|
|
3947
3801
|
params = node.value.params;
|
|
3948
3802
|
}
|
|
3803
|
+
if ((node.type === AST_NODE_TYPES49.FunctionDeclaration || node.type === AST_NODE_TYPES49.FunctionExpression || node.type === AST_NODE_TYPES49.ArrowFunctionExpression) && params.length === 1 && params[0].type === AST_NODE_TYPES49.Identifier && isReactComponentFunction(node)) {
|
|
3804
|
+
return;
|
|
3805
|
+
}
|
|
3949
3806
|
params.forEach((param) => {
|
|
3950
3807
|
if (hasInlineObjectType(param)) {
|
|
3951
3808
|
context.report({
|
|
@@ -3966,12 +3823,91 @@ var preferNamedParamTypes = createRule52({
|
|
|
3966
3823
|
});
|
|
3967
3824
|
var prefer_named_param_types_default = preferNamedParamTypes;
|
|
3968
3825
|
|
|
3826
|
+
// src/rules/prefer-props-with-children.ts
|
|
3827
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES50, ESLintUtils as ESLintUtils50 } from "@typescript-eslint/utils";
|
|
3828
|
+
var createRule50 = ESLintUtils50.RuleCreator(
|
|
3829
|
+
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3830
|
+
);
|
|
3831
|
+
var preferPropsWithChildren = createRule50({
|
|
3832
|
+
name: "prefer-props-with-children",
|
|
3833
|
+
meta: {
|
|
3834
|
+
type: "suggestion",
|
|
3835
|
+
docs: {
|
|
3836
|
+
description: "Prefer PropsWithChildren<T> over manually declaring children: ReactNode in component props"
|
|
3837
|
+
},
|
|
3838
|
+
schema: [],
|
|
3839
|
+
messages: {
|
|
3840
|
+
usePropsWithChildren: "Use 'PropsWithChildren<T>' instead of manually declaring 'children: ReactNode'."
|
|
3841
|
+
}
|
|
3842
|
+
},
|
|
3843
|
+
defaultOptions: [],
|
|
3844
|
+
create(context) {
|
|
3845
|
+
function isReactNodeType(typeNode) {
|
|
3846
|
+
if (!typeNode) {
|
|
3847
|
+
return false;
|
|
3848
|
+
}
|
|
3849
|
+
if (typeNode.type !== AST_NODE_TYPES50.TSTypeReference) {
|
|
3850
|
+
return false;
|
|
3851
|
+
}
|
|
3852
|
+
const { typeName } = typeNode;
|
|
3853
|
+
if (typeName.type === AST_NODE_TYPES50.Identifier) {
|
|
3854
|
+
return typeName.name === "ReactNode";
|
|
3855
|
+
}
|
|
3856
|
+
if (typeName.type === AST_NODE_TYPES50.TSQualifiedName && typeName.left.type === AST_NODE_TYPES50.Identifier && typeName.left.name === "React" && typeName.right.type === AST_NODE_TYPES50.Identifier && typeName.right.name === "ReactNode") {
|
|
3857
|
+
return true;
|
|
3858
|
+
}
|
|
3859
|
+
return false;
|
|
3860
|
+
}
|
|
3861
|
+
function findChildrenReactNode(members) {
|
|
3862
|
+
for (const member of members) {
|
|
3863
|
+
if (member.type !== AST_NODE_TYPES50.TSPropertySignature) {
|
|
3864
|
+
continue;
|
|
3865
|
+
}
|
|
3866
|
+
if (member.key.type !== AST_NODE_TYPES50.Identifier) {
|
|
3867
|
+
continue;
|
|
3868
|
+
}
|
|
3869
|
+
if (member.key.name !== "children") {
|
|
3870
|
+
continue;
|
|
3871
|
+
}
|
|
3872
|
+
if (!member.typeAnnotation) {
|
|
3873
|
+
continue;
|
|
3874
|
+
}
|
|
3875
|
+
if (isReactNodeType(member.typeAnnotation.typeAnnotation)) {
|
|
3876
|
+
return member;
|
|
3877
|
+
}
|
|
3878
|
+
}
|
|
3879
|
+
return void 0;
|
|
3880
|
+
}
|
|
3881
|
+
return {
|
|
3882
|
+
TSInterfaceDeclaration(node) {
|
|
3883
|
+
const childrenMember = findChildrenReactNode(node.body.body);
|
|
3884
|
+
if (childrenMember) {
|
|
3885
|
+
context.report({
|
|
3886
|
+
node: childrenMember,
|
|
3887
|
+
messageId: "usePropsWithChildren"
|
|
3888
|
+
});
|
|
3889
|
+
}
|
|
3890
|
+
},
|
|
3891
|
+
TSTypeLiteral(node) {
|
|
3892
|
+
const childrenMember = findChildrenReactNode(node.members);
|
|
3893
|
+
if (childrenMember) {
|
|
3894
|
+
context.report({
|
|
3895
|
+
node: childrenMember,
|
|
3896
|
+
messageId: "usePropsWithChildren"
|
|
3897
|
+
});
|
|
3898
|
+
}
|
|
3899
|
+
}
|
|
3900
|
+
};
|
|
3901
|
+
}
|
|
3902
|
+
});
|
|
3903
|
+
var prefer_props_with_children_default = preferPropsWithChildren;
|
|
3904
|
+
|
|
3969
3905
|
// src/rules/prefer-react-import-types.ts
|
|
3970
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES51, ESLintUtils as
|
|
3971
|
-
var
|
|
3906
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES51, ESLintUtils as ESLintUtils51 } from "@typescript-eslint/utils";
|
|
3907
|
+
var createRule51 = ESLintUtils51.RuleCreator(
|
|
3972
3908
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3973
3909
|
);
|
|
3974
|
-
var preferReactImportTypes =
|
|
3910
|
+
var preferReactImportTypes = createRule51({
|
|
3975
3911
|
name: "prefer-react-import-types",
|
|
3976
3912
|
meta: {
|
|
3977
3913
|
type: "suggestion",
|
|
@@ -4084,11 +4020,11 @@ var preferReactImportTypes = createRule53({
|
|
|
4084
4020
|
var prefer_react_import_types_default = preferReactImportTypes;
|
|
4085
4021
|
|
|
4086
4022
|
// src/rules/react-props-destructure.ts
|
|
4087
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES52, ESLintUtils as
|
|
4088
|
-
var
|
|
4023
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES52, ESLintUtils as ESLintUtils52 } from "@typescript-eslint/utils";
|
|
4024
|
+
var createRule52 = ESLintUtils52.RuleCreator(
|
|
4089
4025
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
4090
4026
|
);
|
|
4091
|
-
var reactPropsDestructure =
|
|
4027
|
+
var reactPropsDestructure = createRule52({
|
|
4092
4028
|
name: "react-props-destructure",
|
|
4093
4029
|
meta: {
|
|
4094
4030
|
type: "suggestion",
|
|
@@ -4169,8 +4105,8 @@ var reactPropsDestructure = createRule54({
|
|
|
4169
4105
|
var react_props_destructure_default = reactPropsDestructure;
|
|
4170
4106
|
|
|
4171
4107
|
// src/rules/require-explicit-return-type.ts
|
|
4172
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES53, ESLintUtils as
|
|
4173
|
-
var
|
|
4108
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES53, ESLintUtils as ESLintUtils53 } from "@typescript-eslint/utils";
|
|
4109
|
+
var createRule53 = ESLintUtils53.RuleCreator(
|
|
4174
4110
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
4175
4111
|
);
|
|
4176
4112
|
var isReactComponent = (node) => {
|
|
@@ -4219,7 +4155,7 @@ var getFunctionName = (node) => {
|
|
|
4219
4155
|
}
|
|
4220
4156
|
return null;
|
|
4221
4157
|
};
|
|
4222
|
-
var requireExplicitReturnType =
|
|
4158
|
+
var requireExplicitReturnType = createRule53({
|
|
4223
4159
|
name: "require-explicit-return-type",
|
|
4224
4160
|
meta: {
|
|
4225
4161
|
type: "suggestion",
|
|
@@ -4268,8 +4204,8 @@ var requireExplicitReturnType = createRule55({
|
|
|
4268
4204
|
var require_explicit_return_type_default = requireExplicitReturnType;
|
|
4269
4205
|
|
|
4270
4206
|
// src/rules/sort-exports.ts
|
|
4271
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES54, ESLintUtils as
|
|
4272
|
-
var
|
|
4207
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES54, ESLintUtils as ESLintUtils54 } from "@typescript-eslint/utils";
|
|
4208
|
+
var createRule54 = ESLintUtils54.RuleCreator(
|
|
4273
4209
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
4274
4210
|
);
|
|
4275
4211
|
var GROUP_NAMES = ["", "external/alias re-export", "relative re-export", "local export"];
|
|
@@ -4283,7 +4219,7 @@ function getExportGroup(node) {
|
|
|
4283
4219
|
}
|
|
4284
4220
|
return 1;
|
|
4285
4221
|
}
|
|
4286
|
-
var sortExports =
|
|
4222
|
+
var sortExports = createRule54({
|
|
4287
4223
|
name: "sort-exports",
|
|
4288
4224
|
meta: {
|
|
4289
4225
|
type: "suggestion",
|
|
@@ -4342,8 +4278,8 @@ var sortExports = createRule56({
|
|
|
4342
4278
|
var sort_exports_default = sortExports;
|
|
4343
4279
|
|
|
4344
4280
|
// src/rules/sort-imports.ts
|
|
4345
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES55, ESLintUtils as
|
|
4346
|
-
var
|
|
4281
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES55, ESLintUtils as ESLintUtils55 } from "@typescript-eslint/utils";
|
|
4282
|
+
var createRule55 = ESLintUtils55.RuleCreator(
|
|
4347
4283
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
4348
4284
|
);
|
|
4349
4285
|
var NODE_BUILTINS = /* @__PURE__ */ new Set([
|
|
@@ -4410,7 +4346,7 @@ function getImportGroup(node) {
|
|
|
4410
4346
|
function isTypeOnlyImport(node) {
|
|
4411
4347
|
return node.importKind === "type" && node.specifiers.length > 0;
|
|
4412
4348
|
}
|
|
4413
|
-
var sortImports =
|
|
4349
|
+
var sortImports = createRule55({
|
|
4414
4350
|
name: "sort-imports",
|
|
4415
4351
|
meta: {
|
|
4416
4352
|
type: "suggestion",
|
|
@@ -4476,8 +4412,8 @@ var sortImports = createRule57({
|
|
|
4476
4412
|
var sort_imports_default = sortImports;
|
|
4477
4413
|
|
|
4478
4414
|
// src/rules/sort-type-alphabetically.ts
|
|
4479
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES56, ESLintUtils as
|
|
4480
|
-
var
|
|
4415
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES56, ESLintUtils as ESLintUtils56 } from "@typescript-eslint/utils";
|
|
4416
|
+
var createRule56 = ESLintUtils56.RuleCreator(
|
|
4481
4417
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
4482
4418
|
);
|
|
4483
4419
|
function isAlphabeticallySortedWithinGroups(members) {
|
|
@@ -4493,7 +4429,7 @@ function isAlphabeticallySortedWithinGroups(members) {
|
|
|
4493
4429
|
const isOptionalSorted = optional.every((name, index) => index === 0 || optional[index - 1].localeCompare(name) <= 0);
|
|
4494
4430
|
return isRequiredSorted && isOptionalSorted;
|
|
4495
4431
|
}
|
|
4496
|
-
var sortTypeAlphabetically =
|
|
4432
|
+
var sortTypeAlphabetically = createRule56({
|
|
4497
4433
|
name: "sort-type-alphabetically",
|
|
4498
4434
|
meta: {
|
|
4499
4435
|
type: "suggestion",
|
|
@@ -4568,8 +4504,8 @@ var sortTypeAlphabetically = createRule58({
|
|
|
4568
4504
|
var sort_type_alphabetically_default = sortTypeAlphabetically;
|
|
4569
4505
|
|
|
4570
4506
|
// src/rules/sort-type-required-first.ts
|
|
4571
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES57, ESLintUtils as
|
|
4572
|
-
var
|
|
4507
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES57, ESLintUtils as ESLintUtils57 } from "@typescript-eslint/utils";
|
|
4508
|
+
var createRule57 = ESLintUtils57.RuleCreator(
|
|
4573
4509
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
4574
4510
|
);
|
|
4575
4511
|
function isRequiredBeforeOptional(members) {
|
|
@@ -4585,7 +4521,7 @@ function isRequiredBeforeOptional(members) {
|
|
|
4585
4521
|
}
|
|
4586
4522
|
return properties.slice(firstOptionalIndex).every((prop) => prop.optional);
|
|
4587
4523
|
}
|
|
4588
|
-
var sortTypeRequiredFirst =
|
|
4524
|
+
var sortTypeRequiredFirst = createRule57({
|
|
4589
4525
|
name: "sort-type-required-first",
|
|
4590
4526
|
meta: {
|
|
4591
4527
|
type: "suggestion",
|
|
@@ -4652,7 +4588,6 @@ var rules = {
|
|
|
4652
4588
|
"boolean-naming-prefix": boolean_naming_prefix_default,
|
|
4653
4589
|
"enforce-camel-case": enforce_camel_case_default,
|
|
4654
4590
|
"enforce-constant-case": enforce_constant_case_default,
|
|
4655
|
-
"enforce-curly-newline": enforce_curly_newline_default,
|
|
4656
4591
|
"enforce-hook-naming": enforce_hook_naming_default,
|
|
4657
4592
|
"enforce-property-case": enforce_property_case_default,
|
|
4658
4593
|
"enforce-props-suffix": enforce_props_suffix_default,
|
|
@@ -4660,7 +4595,6 @@ var rules = {
|
|
|
4660
4595
|
"enforce-service-naming": enforce_service_naming_default,
|
|
4661
4596
|
"enforce-sorted-destructuring": enforce_sorted_destructuring_default,
|
|
4662
4597
|
"enforce-type-declaration-order": enforce_type_declaration_order_default,
|
|
4663
|
-
"file-kebab-case": file_kebab_case_default,
|
|
4664
4598
|
"index-export-only": index_export_only_default,
|
|
4665
4599
|
"jsx-newline-between-elements": jsx_newline_between_elements_default,
|
|
4666
4600
|
"jsx-no-inline-object-prop": jsx_no_inline_object_prop_default,
|
|
@@ -4668,14 +4602,12 @@ var rules = {
|
|
|
4668
4602
|
"jsx-no-non-component-function": jsx_no_non_component_function_default,
|
|
4669
4603
|
"jsx-no-ternary-null": jsx_no_ternary_null_default,
|
|
4670
4604
|
"jsx-no-variable-in-callback": jsx_no_variable_in_callback_default,
|
|
4671
|
-
"jsx-pascal-case": jsx_pascal_case_default,
|
|
4672
4605
|
"jsx-require-suspense": jsx_require_suspense_default,
|
|
4673
4606
|
"jsx-simple-props": jsx_simple_props_default,
|
|
4674
4607
|
"jsx-sort-props": jsx_sort_props_default,
|
|
4675
4608
|
"jsx-spread-props-last": jsx_spread_props_last_default,
|
|
4676
4609
|
"newline-after-multiline-block": newline_after_multiline_block_default,
|
|
4677
4610
|
"newline-before-return": newline_before_return_default,
|
|
4678
|
-
"nextjs-require-public-env": nextjs_require_public_env_default,
|
|
4679
4611
|
"no-complex-inline-return": no_complex_inline_return_default,
|
|
4680
4612
|
"no-direct-date": no_direct_date_default,
|
|
4681
4613
|
"no-emoji": no_emoji_default,
|
|
@@ -4698,9 +4630,11 @@ var rules = {
|
|
|
4698
4630
|
"prefer-import-type": prefer_import_type_default,
|
|
4699
4631
|
"prefer-inline-literal-union": prefer_inline_literal_union_default,
|
|
4700
4632
|
"prefer-inline-type-export": prefer_inline_type_export_default,
|
|
4633
|
+
"prefer-interface-for-component-props": prefer_interface_for_component_props_default,
|
|
4701
4634
|
"prefer-interface-over-inline-types": prefer_interface_over_inline_types_default,
|
|
4702
4635
|
"prefer-jsx-template-literals": prefer_jsx_template_literals_default,
|
|
4703
4636
|
"prefer-named-param-types": prefer_named_param_types_default,
|
|
4637
|
+
"prefer-props-with-children": prefer_props_with_children_default,
|
|
4704
4638
|
"prefer-react-import-types": prefer_react_import_types_default,
|
|
4705
4639
|
"react-props-destructure": react_props_destructure_default,
|
|
4706
4640
|
"require-explicit-return-type": require_explicit_return_type_default,
|
|
@@ -4717,13 +4651,11 @@ var baseRules = {
|
|
|
4717
4651
|
"nextfriday/boolean-naming-prefix": "warn",
|
|
4718
4652
|
"nextfriday/enforce-camel-case": "warn",
|
|
4719
4653
|
"nextfriday/enforce-constant-case": "warn",
|
|
4720
|
-
"nextfriday/enforce-curly-newline": "warn",
|
|
4721
4654
|
"nextfriday/enforce-hook-naming": "warn",
|
|
4722
4655
|
"nextfriday/enforce-property-case": "warn",
|
|
4723
4656
|
"nextfriday/enforce-service-naming": "warn",
|
|
4724
4657
|
"nextfriday/enforce-sorted-destructuring": "warn",
|
|
4725
4658
|
"nextfriday/enforce-type-declaration-order": "warn",
|
|
4726
|
-
"nextfriday/file-kebab-case": "warn",
|
|
4727
4659
|
"nextfriday/index-export-only": "warn",
|
|
4728
4660
|
"nextfriday/newline-after-multiline-block": "warn",
|
|
4729
4661
|
"nextfriday/newline-before-return": "warn",
|
|
@@ -4761,13 +4693,11 @@ var baseRecommendedRules = {
|
|
|
4761
4693
|
"nextfriday/boolean-naming-prefix": "error",
|
|
4762
4694
|
"nextfriday/enforce-camel-case": "error",
|
|
4763
4695
|
"nextfriday/enforce-constant-case": "error",
|
|
4764
|
-
"nextfriday/enforce-curly-newline": "error",
|
|
4765
4696
|
"nextfriday/enforce-hook-naming": "error",
|
|
4766
4697
|
"nextfriday/enforce-property-case": "error",
|
|
4767
4698
|
"nextfriday/enforce-service-naming": "error",
|
|
4768
4699
|
"nextfriday/enforce-sorted-destructuring": "error",
|
|
4769
4700
|
"nextfriday/enforce-type-declaration-order": "error",
|
|
4770
|
-
"nextfriday/file-kebab-case": "error",
|
|
4771
4701
|
"nextfriday/index-export-only": "error",
|
|
4772
4702
|
"nextfriday/newline-after-multiline-block": "error",
|
|
4773
4703
|
"nextfriday/newline-before-return": "error",
|
|
@@ -4810,13 +4740,14 @@ var jsxRules = {
|
|
|
4810
4740
|
"nextfriday/jsx-no-non-component-function": "warn",
|
|
4811
4741
|
"nextfriday/jsx-no-ternary-null": "warn",
|
|
4812
4742
|
"nextfriday/jsx-no-variable-in-callback": "warn",
|
|
4813
|
-
"nextfriday/jsx-pascal-case": "warn",
|
|
4814
4743
|
"nextfriday/jsx-require-suspense": "warn",
|
|
4815
4744
|
"nextfriday/jsx-simple-props": "warn",
|
|
4816
4745
|
"nextfriday/jsx-sort-props": "warn",
|
|
4817
4746
|
"nextfriday/jsx-spread-props-last": "warn",
|
|
4747
|
+
"nextfriday/prefer-interface-for-component-props": "warn",
|
|
4818
4748
|
"nextfriday/prefer-interface-over-inline-types": "warn",
|
|
4819
4749
|
"nextfriday/prefer-jsx-template-literals": "warn",
|
|
4750
|
+
"nextfriday/prefer-props-with-children": "warn",
|
|
4820
4751
|
"nextfriday/react-props-destructure": "warn"
|
|
4821
4752
|
};
|
|
4822
4753
|
var jsxRecommendedRules = {
|
|
@@ -4828,41 +4759,22 @@ var jsxRecommendedRules = {
|
|
|
4828
4759
|
"nextfriday/jsx-no-non-component-function": "error",
|
|
4829
4760
|
"nextfriday/jsx-no-ternary-null": "error",
|
|
4830
4761
|
"nextfriday/jsx-no-variable-in-callback": "error",
|
|
4831
|
-
"nextfriday/jsx-pascal-case": "error",
|
|
4832
4762
|
"nextfriday/jsx-require-suspense": "error",
|
|
4833
4763
|
"nextfriday/jsx-simple-props": "error",
|
|
4834
4764
|
"nextfriday/jsx-sort-props": "error",
|
|
4835
4765
|
"nextfriday/jsx-spread-props-last": "error",
|
|
4766
|
+
"nextfriday/prefer-interface-for-component-props": "error",
|
|
4836
4767
|
"nextfriday/prefer-interface-over-inline-types": "error",
|
|
4837
4768
|
"nextfriday/prefer-jsx-template-literals": "error",
|
|
4769
|
+
"nextfriday/prefer-props-with-children": "error",
|
|
4838
4770
|
"nextfriday/react-props-destructure": "error"
|
|
4839
4771
|
};
|
|
4840
|
-
var nextjsOnlyRules = {
|
|
4841
|
-
"nextfriday/nextjs-require-public-env": "warn"
|
|
4842
|
-
};
|
|
4843
|
-
var nextjsOnlyRecommendedRules = {
|
|
4844
|
-
"nextfriday/nextjs-require-public-env": "error"
|
|
4845
|
-
};
|
|
4846
4772
|
var createConfig = (configRules) => ({
|
|
4847
4773
|
plugins: {
|
|
4848
4774
|
nextfriday: plugin
|
|
4849
4775
|
},
|
|
4850
4776
|
rules: configRules
|
|
4851
4777
|
});
|
|
4852
|
-
var NEXTJS_ROUTING_GLOBS = [
|
|
4853
|
-
"app/**/*.{js,jsx,ts,tsx}",
|
|
4854
|
-
"src/app/**/*.{js,jsx,ts,tsx}",
|
|
4855
|
-
"pages/**/*.{js,jsx,ts,tsx}",
|
|
4856
|
-
"src/pages/**/*.{js,jsx,ts,tsx}"
|
|
4857
|
-
];
|
|
4858
|
-
var nextjsRoutingOverride = {
|
|
4859
|
-
files: NEXTJS_ROUTING_GLOBS,
|
|
4860
|
-
rules: {
|
|
4861
|
-
"nextfriday/file-kebab-case": "off",
|
|
4862
|
-
"nextfriday/jsx-pascal-case": "off"
|
|
4863
|
-
}
|
|
4864
|
-
};
|
|
4865
|
-
var createNextjsConfig = (configRules) => [createConfig(configRules), nextjsRoutingOverride];
|
|
4866
4778
|
var configs = {
|
|
4867
4779
|
base: createConfig(baseRules),
|
|
4868
4780
|
"base/recommended": createConfig(baseRecommendedRules),
|
|
@@ -4874,15 +4786,13 @@ var configs = {
|
|
|
4874
4786
|
...baseRecommendedRules,
|
|
4875
4787
|
...jsxRecommendedRules
|
|
4876
4788
|
}),
|
|
4877
|
-
nextjs:
|
|
4789
|
+
nextjs: createConfig({
|
|
4878
4790
|
...baseRules,
|
|
4879
|
-
...jsxRules
|
|
4880
|
-
...nextjsOnlyRules
|
|
4791
|
+
...jsxRules
|
|
4881
4792
|
}),
|
|
4882
|
-
"nextjs/recommended":
|
|
4793
|
+
"nextjs/recommended": createConfig({
|
|
4883
4794
|
...baseRecommendedRules,
|
|
4884
|
-
...jsxRecommendedRules
|
|
4885
|
-
...nextjsOnlyRecommendedRules
|
|
4795
|
+
...jsxRecommendedRules
|
|
4886
4796
|
})
|
|
4887
4797
|
};
|
|
4888
4798
|
var nextfridayPlugin = {
|