eslint-plugin-nextfriday 2.0.0 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +46 -0
- package/README.md +134 -8
- package/docs/rules/BOOLEAN_NAMING_PREFIX.md +13 -0
- package/docs/rules/ENFORCE_CONSTANT_CASE.md +31 -0
- package/docs/rules/FILE_KEBAB_CASE.md +31 -0
- package/docs/rules/JSX_PASCAL_CASE.md +30 -0
- package/lib/index.cjs +447 -468
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +26 -62
- package/lib/index.d.ts +26 -62
- package/lib/index.js +100 -123
- package/lib/index.js.map +1 -1
- package/package.json +2 -3
package/lib/index.js
CHANGED
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
// src/index.ts
|
|
2
|
-
import rawSonarjs from "eslint-plugin-sonarjs";
|
|
3
|
-
import rawUnicorn from "eslint-plugin-unicorn";
|
|
4
|
-
|
|
5
1
|
// package.json
|
|
6
2
|
var package_default = {
|
|
7
3
|
name: "eslint-plugin-nextfriday",
|
|
8
|
-
version: "
|
|
4
|
+
version: "3.0.0",
|
|
9
5
|
description: "A comprehensive ESLint plugin providing custom rules and configurations for Next Friday development workflows.",
|
|
10
6
|
keywords: [
|
|
11
7
|
"eslint",
|
|
@@ -50,6 +46,7 @@ var package_default = {
|
|
|
50
46
|
"lib"
|
|
51
47
|
],
|
|
52
48
|
scripts: {
|
|
49
|
+
audit: "pnpm audit --prod --audit-level high",
|
|
53
50
|
build: "tsup",
|
|
54
51
|
changeset: "changeset",
|
|
55
52
|
"changeset:publish": "npm publish --provenance --access public",
|
|
@@ -71,8 +68,6 @@ var package_default = {
|
|
|
71
68
|
dependencies: {
|
|
72
69
|
"@typescript-eslint/utils": "^8.59.1",
|
|
73
70
|
"emoji-regex": "^10.6.0",
|
|
74
|
-
"eslint-plugin-sonarjs": "^4.0.3",
|
|
75
|
-
"eslint-plugin-unicorn": "^64.0.0",
|
|
76
71
|
tsup: "^8.5.1"
|
|
77
72
|
},
|
|
78
73
|
devDependencies: {
|
|
@@ -395,7 +390,19 @@ var enforceCamelCase = createRule2({
|
|
|
395
390
|
var enforce_camel_case_default = enforceCamelCase;
|
|
396
391
|
|
|
397
392
|
// src/rules/enforce-constant-case.ts
|
|
398
|
-
import { AST_NODE_TYPES as
|
|
393
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES4, ESLintUtils as ESLintUtils3 } from "@typescript-eslint/utils";
|
|
394
|
+
|
|
395
|
+
// src/utils.ts
|
|
396
|
+
import { basename, extname } from "path";
|
|
397
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES3 } from "@typescript-eslint/utils";
|
|
398
|
+
var getFileExtension = (filename) => extname(filename).slice(1);
|
|
399
|
+
var getBaseName = (filename) => basename(filename, extname(filename));
|
|
400
|
+
var isConfigFile = (filename) => {
|
|
401
|
+
const baseName = getBaseName(filename);
|
|
402
|
+
return /\.(config|rc|setup|spec|test)$/.test(baseName) || /\.(config|rc|setup|spec|test)\./.test(filename) || /^\.(eslintrc|babelrc|prettierrc)/.test(filename);
|
|
403
|
+
};
|
|
404
|
+
|
|
405
|
+
// src/rules/enforce-constant-case.ts
|
|
399
406
|
var createRule3 = ESLintUtils3.RuleCreator(
|
|
400
407
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
401
408
|
);
|
|
@@ -413,42 +420,42 @@ var startsWithBooleanPrefix2 = (name) => BOOLEAN_PREFIXES2.some((prefix) => {
|
|
|
413
420
|
const nextChar = name.charAt(prefix.length);
|
|
414
421
|
return nextChar === nextChar.toUpperCase() && nextChar !== nextChar.toLowerCase();
|
|
415
422
|
});
|
|
416
|
-
var isBooleanLiteral2 = (init) => init.type ===
|
|
417
|
-
var isAsConstAssertion = (node) => node.type ===
|
|
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";
|
|
418
425
|
var isStaticValue2 = (init) => {
|
|
419
426
|
if (isAsConstAssertion(init)) {
|
|
420
427
|
return true;
|
|
421
428
|
}
|
|
422
|
-
if (init.type ===
|
|
429
|
+
if (init.type === AST_NODE_TYPES4.Literal) {
|
|
423
430
|
return true;
|
|
424
431
|
}
|
|
425
|
-
if (init.type ===
|
|
432
|
+
if (init.type === AST_NODE_TYPES4.UnaryExpression && init.argument.type === AST_NODE_TYPES4.Literal) {
|
|
426
433
|
return true;
|
|
427
434
|
}
|
|
428
|
-
if (init.type ===
|
|
435
|
+
if (init.type === AST_NODE_TYPES4.TemplateLiteral && init.expressions.length === 0) {
|
|
429
436
|
return true;
|
|
430
437
|
}
|
|
431
|
-
if (init.type ===
|
|
432
|
-
return init.elements.every((el) => el !== null && el.type !==
|
|
438
|
+
if (init.type === AST_NODE_TYPES4.ArrayExpression) {
|
|
439
|
+
return init.elements.every((el) => el !== null && el.type !== AST_NODE_TYPES4.SpreadElement && isStaticValue2(el));
|
|
433
440
|
}
|
|
434
|
-
if (init.type ===
|
|
441
|
+
if (init.type === AST_NODE_TYPES4.ObjectExpression) {
|
|
435
442
|
return init.properties.every(
|
|
436
|
-
(prop) => prop.type ===
|
|
443
|
+
(prop) => prop.type === AST_NODE_TYPES4.Property && isStaticValue2(prop.value)
|
|
437
444
|
);
|
|
438
445
|
}
|
|
439
446
|
return false;
|
|
440
447
|
};
|
|
441
448
|
var isGlobalScope2 = (node) => {
|
|
442
449
|
const { parent } = node;
|
|
443
|
-
if (parent.type ===
|
|
450
|
+
if (parent.type === AST_NODE_TYPES4.Program) {
|
|
444
451
|
return true;
|
|
445
452
|
}
|
|
446
|
-
if (parent.type ===
|
|
453
|
+
if (parent.type === AST_NODE_TYPES4.ExportNamedDeclaration && parent.parent?.type === AST_NODE_TYPES4.Program) {
|
|
447
454
|
return true;
|
|
448
455
|
}
|
|
449
456
|
return false;
|
|
450
457
|
};
|
|
451
|
-
var isFunctionOrComponent = (init) => init.type ===
|
|
458
|
+
var isFunctionOrComponent = (init) => init.type === AST_NODE_TYPES4.ArrowFunctionExpression || init.type === AST_NODE_TYPES4.FunctionExpression;
|
|
452
459
|
var enforceConstantCase = createRule3({
|
|
453
460
|
name: "enforce-constant-case",
|
|
454
461
|
meta: {
|
|
@@ -464,13 +471,16 @@ var enforceConstantCase = createRule3({
|
|
|
464
471
|
},
|
|
465
472
|
defaultOptions: [],
|
|
466
473
|
create(context) {
|
|
474
|
+
if (isConfigFile(context.filename)) {
|
|
475
|
+
return {};
|
|
476
|
+
}
|
|
467
477
|
return {
|
|
468
478
|
VariableDeclaration(node) {
|
|
469
479
|
if (node.kind !== "const" || !isGlobalScope2(node)) {
|
|
470
480
|
return;
|
|
471
481
|
}
|
|
472
482
|
node.declarations.forEach((declarator) => {
|
|
473
|
-
if (declarator.id.type !==
|
|
483
|
+
if (declarator.id.type !== AST_NODE_TYPES4.Identifier || !declarator.init) {
|
|
474
484
|
return;
|
|
475
485
|
}
|
|
476
486
|
if (isFunctionOrComponent(declarator.init)) {
|
|
@@ -506,7 +516,7 @@ var enforceConstantCase = createRule3({
|
|
|
506
516
|
var enforce_constant_case_default = enforceConstantCase;
|
|
507
517
|
|
|
508
518
|
// src/rules/enforce-curly-newline.ts
|
|
509
|
-
import { AST_NODE_TYPES as
|
|
519
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES5, ESLintUtils as ESLintUtils4 } from "@typescript-eslint/utils";
|
|
510
520
|
var createRule4 = ESLintUtils4.RuleCreator(
|
|
511
521
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
512
522
|
);
|
|
@@ -533,7 +543,7 @@ var enforceCurlyNewline = createRule4({
|
|
|
533
543
|
const startLine = node.loc.start.line;
|
|
534
544
|
const endLine = node.loc.end.line;
|
|
535
545
|
const isSingleLine2 = startLine === endLine;
|
|
536
|
-
const hasBraces = consequent.type ===
|
|
546
|
+
const hasBraces = consequent.type === AST_NODE_TYPES5.BlockStatement;
|
|
537
547
|
if (isSingleLine2 && hasBraces) {
|
|
538
548
|
if (consequent.body.length !== 1) {
|
|
539
549
|
return;
|
|
@@ -578,7 +588,7 @@ var enforce_curly_newline_default = enforceCurlyNewline;
|
|
|
578
588
|
|
|
579
589
|
// src/rules/enforce-hook-naming.ts
|
|
580
590
|
import path from "path";
|
|
581
|
-
import { AST_NODE_TYPES as
|
|
591
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES6, ESLintUtils as ESLintUtils5 } from "@typescript-eslint/utils";
|
|
582
592
|
var createRule5 = ESLintUtils5.RuleCreator(
|
|
583
593
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
584
594
|
);
|
|
@@ -621,22 +631,22 @@ var enforceHookNaming = createRule5({
|
|
|
621
631
|
};
|
|
622
632
|
return {
|
|
623
633
|
ExportNamedDeclaration(node) {
|
|
624
|
-
if (node.declaration?.type ===
|
|
634
|
+
if (node.declaration?.type === AST_NODE_TYPES6.FunctionDeclaration && node.declaration.id) {
|
|
625
635
|
checkFunctionName(node.declaration.id.name, node.declaration.id, "missingUsePrefix");
|
|
626
636
|
}
|
|
627
|
-
if (node.declaration?.type ===
|
|
637
|
+
if (node.declaration?.type === AST_NODE_TYPES6.VariableDeclaration) {
|
|
628
638
|
node.declaration.declarations.forEach((declarator) => {
|
|
629
|
-
if (declarator.id.type ===
|
|
639
|
+
if (declarator.id.type === AST_NODE_TYPES6.Identifier) {
|
|
630
640
|
checkFunctionName(declarator.id.name, declarator.id, "missingUsePrefix");
|
|
631
641
|
}
|
|
632
642
|
});
|
|
633
643
|
}
|
|
634
644
|
},
|
|
635
645
|
ExportDefaultDeclaration(node) {
|
|
636
|
-
if (node.declaration.type ===
|
|
646
|
+
if (node.declaration.type === AST_NODE_TYPES6.Identifier) {
|
|
637
647
|
checkFunctionName(node.declaration.name, node.declaration, "defaultExportMissingUsePrefix");
|
|
638
648
|
}
|
|
639
|
-
if (node.declaration.type ===
|
|
649
|
+
if (node.declaration.type === AST_NODE_TYPES6.FunctionDeclaration && node.declaration.id) {
|
|
640
650
|
checkFunctionName(node.declaration.id.name, node.declaration.id, "defaultExportMissingUsePrefix");
|
|
641
651
|
}
|
|
642
652
|
}
|
|
@@ -646,7 +656,7 @@ var enforceHookNaming = createRule5({
|
|
|
646
656
|
var enforce_hook_naming_default = enforceHookNaming;
|
|
647
657
|
|
|
648
658
|
// src/rules/enforce-property-case.ts
|
|
649
|
-
import { AST_NODE_TYPES as
|
|
659
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES7, ESLintUtils as ESLintUtils6 } from "@typescript-eslint/utils";
|
|
650
660
|
var createRule6 = ESLintUtils6.RuleCreator(
|
|
651
661
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
652
662
|
);
|
|
@@ -654,12 +664,12 @@ var SNAKE_CASE_REGEX3 = /^[a-z]+_[a-z0-9_]*$/;
|
|
|
654
664
|
var SCREAMING_SNAKE_CASE_REGEX2 = /^[A-Z][A-Z0-9]*(?:_[A-Z0-9]+)*$/;
|
|
655
665
|
var isInsideAsConst = (node) => {
|
|
656
666
|
const { parent } = node;
|
|
657
|
-
if (parent.type ===
|
|
667
|
+
if (parent.type === AST_NODE_TYPES7.TSAsExpression && parent.typeAnnotation.type === AST_NODE_TYPES7.TSTypeReference && parent.typeAnnotation.typeName.type === AST_NODE_TYPES7.Identifier && parent.typeAnnotation.typeName.name === "const") {
|
|
658
668
|
return true;
|
|
659
669
|
}
|
|
660
|
-
if (parent.type ===
|
|
670
|
+
if (parent.type === AST_NODE_TYPES7.ArrayExpression) {
|
|
661
671
|
const grandparent = parent.parent;
|
|
662
|
-
if (grandparent?.type ===
|
|
672
|
+
if (grandparent?.type === AST_NODE_TYPES7.TSAsExpression && grandparent.typeAnnotation.type === AST_NODE_TYPES7.TSTypeReference && grandparent.typeAnnotation.typeName.type === AST_NODE_TYPES7.Identifier && grandparent.typeAnnotation.typeName.name === "const") {
|
|
663
673
|
return true;
|
|
664
674
|
}
|
|
665
675
|
}
|
|
@@ -681,7 +691,7 @@ var enforcePropertyCase = createRule6({
|
|
|
681
691
|
create(context) {
|
|
682
692
|
return {
|
|
683
693
|
Property(node) {
|
|
684
|
-
if (node.parent.type !==
|
|
694
|
+
if (node.parent.type !== AST_NODE_TYPES7.ObjectExpression) {
|
|
685
695
|
return;
|
|
686
696
|
}
|
|
687
697
|
if (isInsideAsConst(node.parent)) {
|
|
@@ -690,7 +700,7 @@ var enforcePropertyCase = createRule6({
|
|
|
690
700
|
if (node.computed) {
|
|
691
701
|
return;
|
|
692
702
|
}
|
|
693
|
-
if (node.key.type !==
|
|
703
|
+
if (node.key.type !== AST_NODE_TYPES7.Identifier) {
|
|
694
704
|
return;
|
|
695
705
|
}
|
|
696
706
|
const { name } = node.key;
|
|
@@ -709,7 +719,7 @@ var enforce_property_case_default = enforcePropertyCase;
|
|
|
709
719
|
|
|
710
720
|
// src/rules/enforce-props-suffix.ts
|
|
711
721
|
import path2 from "path";
|
|
712
|
-
import { AST_NODE_TYPES as
|
|
722
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES8, ESLintUtils as ESLintUtils7 } from "@typescript-eslint/utils";
|
|
713
723
|
var createRule7 = ESLintUtils7.RuleCreator(
|
|
714
724
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
715
725
|
);
|
|
@@ -747,13 +757,13 @@ var enforcePropsSuffix = createRule7({
|
|
|
747
757
|
};
|
|
748
758
|
return {
|
|
749
759
|
TSInterfaceDeclaration(node) {
|
|
750
|
-
if (node.id.type ===
|
|
760
|
+
if (node.id.type === AST_NODE_TYPES8.Identifier) {
|
|
751
761
|
checkTypeName(node.id.name, node.id);
|
|
752
762
|
}
|
|
753
763
|
},
|
|
754
764
|
TSTypeAliasDeclaration(node) {
|
|
755
|
-
if (node.id.type ===
|
|
756
|
-
if (node.typeAnnotation.type ===
|
|
765
|
+
if (node.id.type === AST_NODE_TYPES8.Identifier) {
|
|
766
|
+
if (node.typeAnnotation.type === AST_NODE_TYPES8.TSTypeLiteral) {
|
|
757
767
|
checkTypeName(node.id.name, node.id);
|
|
758
768
|
}
|
|
759
769
|
}
|
|
@@ -764,7 +774,7 @@ var enforcePropsSuffix = createRule7({
|
|
|
764
774
|
var enforce_props_suffix_default = enforcePropsSuffix;
|
|
765
775
|
|
|
766
776
|
// src/rules/enforce-readonly-component-props.ts
|
|
767
|
-
import { AST_NODE_TYPES as
|
|
777
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES9, ESLintUtils as ESLintUtils8 } from "@typescript-eslint/utils";
|
|
768
778
|
var createRule8 = ESLintUtils8.RuleCreator(
|
|
769
779
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
770
780
|
);
|
|
@@ -784,40 +794,40 @@ var enforceReadonlyComponentProps = createRule8({
|
|
|
784
794
|
defaultOptions: [],
|
|
785
795
|
create(context) {
|
|
786
796
|
function hasJSXInConditional(node) {
|
|
787
|
-
return node.consequent.type ===
|
|
797
|
+
return node.consequent.type === AST_NODE_TYPES9.JSXElement || node.consequent.type === AST_NODE_TYPES9.JSXFragment || node.alternate.type === AST_NODE_TYPES9.JSXElement || node.alternate.type === AST_NODE_TYPES9.JSXFragment;
|
|
788
798
|
}
|
|
789
799
|
function hasJSXInLogical(node) {
|
|
790
|
-
return node.right.type ===
|
|
800
|
+
return node.right.type === AST_NODE_TYPES9.JSXElement || node.right.type === AST_NODE_TYPES9.JSXFragment;
|
|
791
801
|
}
|
|
792
802
|
function hasJSXReturn(block) {
|
|
793
803
|
return block.body.some((stmt) => {
|
|
794
|
-
if (stmt.type ===
|
|
795
|
-
return stmt.argument.type ===
|
|
804
|
+
if (stmt.type === AST_NODE_TYPES9.ReturnStatement && stmt.argument) {
|
|
805
|
+
return stmt.argument.type === AST_NODE_TYPES9.JSXElement || stmt.argument.type === AST_NODE_TYPES9.JSXFragment || stmt.argument.type === AST_NODE_TYPES9.ConditionalExpression && hasJSXInConditional(stmt.argument) || stmt.argument.type === AST_NODE_TYPES9.LogicalExpression && hasJSXInLogical(stmt.argument);
|
|
796
806
|
}
|
|
797
807
|
return false;
|
|
798
808
|
});
|
|
799
809
|
}
|
|
800
810
|
function isReactComponent2(node) {
|
|
801
|
-
if (node.type ===
|
|
802
|
-
if (node.body.type ===
|
|
811
|
+
if (node.type === AST_NODE_TYPES9.ArrowFunctionExpression) {
|
|
812
|
+
if (node.body.type === AST_NODE_TYPES9.JSXElement || node.body.type === AST_NODE_TYPES9.JSXFragment) {
|
|
803
813
|
return true;
|
|
804
814
|
}
|
|
805
|
-
if (node.body.type ===
|
|
815
|
+
if (node.body.type === AST_NODE_TYPES9.BlockStatement) {
|
|
806
816
|
return hasJSXReturn(node.body);
|
|
807
817
|
}
|
|
808
|
-
} else if (node.type ===
|
|
809
|
-
if (node.body && node.body.type ===
|
|
818
|
+
} else if (node.type === AST_NODE_TYPES9.FunctionExpression || node.type === AST_NODE_TYPES9.FunctionDeclaration) {
|
|
819
|
+
if (node.body && node.body.type === AST_NODE_TYPES9.BlockStatement) {
|
|
810
820
|
return hasJSXReturn(node.body);
|
|
811
821
|
}
|
|
812
822
|
}
|
|
813
823
|
return false;
|
|
814
824
|
}
|
|
815
825
|
function isNamedType(node) {
|
|
816
|
-
return node.type ===
|
|
826
|
+
return node.type === AST_NODE_TYPES9.TSTypeReference;
|
|
817
827
|
}
|
|
818
828
|
function isAlreadyReadonly(node) {
|
|
819
|
-
if (node.type ===
|
|
820
|
-
if (node.typeName.type ===
|
|
829
|
+
if (node.type === AST_NODE_TYPES9.TSTypeReference && node.typeName) {
|
|
830
|
+
if (node.typeName.type === AST_NODE_TYPES9.Identifier && node.typeName.name === "Readonly") {
|
|
821
831
|
return true;
|
|
822
832
|
}
|
|
823
833
|
}
|
|
@@ -831,7 +841,7 @@ var enforceReadonlyComponentProps = createRule8({
|
|
|
831
841
|
return;
|
|
832
842
|
}
|
|
833
843
|
const param = node.params[0];
|
|
834
|
-
if (param.type ===
|
|
844
|
+
if (param.type === AST_NODE_TYPES9.Identifier && param.typeAnnotation) {
|
|
835
845
|
const { typeAnnotation } = param.typeAnnotation;
|
|
836
846
|
if (isNamedType(typeAnnotation) && !isAlreadyReadonly(typeAnnotation)) {
|
|
837
847
|
const { sourceCode } = context;
|
|
@@ -856,7 +866,7 @@ var enforceReadonlyComponentProps = createRule8({
|
|
|
856
866
|
var enforce_readonly_component_props_default = enforceReadonlyComponentProps;
|
|
857
867
|
|
|
858
868
|
// src/rules/enforce-service-naming.ts
|
|
859
|
-
import { AST_NODE_TYPES as
|
|
869
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES10, ESLintUtils as ESLintUtils9 } from "@typescript-eslint/utils";
|
|
860
870
|
var createRule9 = ESLintUtils9.RuleCreator(
|
|
861
871
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
862
872
|
);
|
|
@@ -909,12 +919,12 @@ var enforceServiceNaming = createRule9({
|
|
|
909
919
|
};
|
|
910
920
|
return {
|
|
911
921
|
ExportNamedDeclaration(node) {
|
|
912
|
-
if (node.declaration?.type ===
|
|
922
|
+
if (node.declaration?.type === AST_NODE_TYPES10.FunctionDeclaration && node.declaration.id) {
|
|
913
923
|
checkExportedFunction(node.declaration, node.declaration.id);
|
|
914
924
|
}
|
|
915
|
-
if (node.declaration?.type ===
|
|
925
|
+
if (node.declaration?.type === AST_NODE_TYPES10.VariableDeclaration) {
|
|
916
926
|
node.declaration.declarations.forEach((declarator) => {
|
|
917
|
-
if (declarator.id.type ===
|
|
927
|
+
if (declarator.id.type === AST_NODE_TYPES10.Identifier && declarator.init?.type === AST_NODE_TYPES10.ArrowFunctionExpression) {
|
|
918
928
|
checkExportedFunction(declarator.init, declarator.id);
|
|
919
929
|
}
|
|
920
930
|
});
|
|
@@ -926,7 +936,7 @@ var enforceServiceNaming = createRule9({
|
|
|
926
936
|
var enforce_service_naming_default = enforceServiceNaming;
|
|
927
937
|
|
|
928
938
|
// src/rules/enforce-sorted-destructuring.ts
|
|
929
|
-
import { AST_NODE_TYPES as
|
|
939
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES11, ESLintUtils as ESLintUtils10 } from "@typescript-eslint/utils";
|
|
930
940
|
var createRule10 = ESLintUtils10.RuleCreator(
|
|
931
941
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
932
942
|
);
|
|
@@ -946,19 +956,19 @@ var enforceSortedDestructuring = createRule10({
|
|
|
946
956
|
defaultOptions: [],
|
|
947
957
|
create(context) {
|
|
948
958
|
function getPropertyName(property) {
|
|
949
|
-
if (property.type ===
|
|
959
|
+
if (property.type === AST_NODE_TYPES11.RestElement) {
|
|
950
960
|
return null;
|
|
951
961
|
}
|
|
952
|
-
if (property.key.type ===
|
|
962
|
+
if (property.key.type === AST_NODE_TYPES11.Identifier) {
|
|
953
963
|
return property.key.name;
|
|
954
964
|
}
|
|
955
965
|
return null;
|
|
956
966
|
}
|
|
957
967
|
function hasDefaultValue(property) {
|
|
958
|
-
return property.value.type ===
|
|
968
|
+
return property.value.type === AST_NODE_TYPES11.AssignmentPattern && Boolean(property.value.right);
|
|
959
969
|
}
|
|
960
970
|
function checkVariableDeclarator(node) {
|
|
961
|
-
if (node.id.type !==
|
|
971
|
+
if (node.id.type !== AST_NODE_TYPES11.ObjectPattern) {
|
|
962
972
|
return;
|
|
963
973
|
}
|
|
964
974
|
const { properties } = node.id;
|
|
@@ -966,7 +976,7 @@ var enforceSortedDestructuring = createRule10({
|
|
|
966
976
|
return;
|
|
967
977
|
}
|
|
968
978
|
const propertyInfo = properties.map((prop) => {
|
|
969
|
-
if (prop.type ===
|
|
979
|
+
if (prop.type === AST_NODE_TYPES11.RestElement) {
|
|
970
980
|
return null;
|
|
971
981
|
}
|
|
972
982
|
return {
|
|
@@ -1005,15 +1015,15 @@ var enforceSortedDestructuring = createRule10({
|
|
|
1005
1015
|
var enforce_sorted_destructuring_default = enforceSortedDestructuring;
|
|
1006
1016
|
|
|
1007
1017
|
// src/rules/enforce-type-declaration-order.ts
|
|
1008
|
-
import { AST_NODE_TYPES as
|
|
1018
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES12, ESLintUtils as ESLintUtils11 } from "@typescript-eslint/utils";
|
|
1009
1019
|
var createRule11 = ESLintUtils11.RuleCreator(
|
|
1010
1020
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1011
1021
|
);
|
|
1012
1022
|
function getTypeDeclarationName(node) {
|
|
1013
|
-
if (node.type ===
|
|
1023
|
+
if (node.type === AST_NODE_TYPES12.TSInterfaceDeclaration && node.id.type === AST_NODE_TYPES12.Identifier) {
|
|
1014
1024
|
return { name: node.id.name, position: node.range[0] };
|
|
1015
1025
|
}
|
|
1016
|
-
if (node.type ===
|
|
1026
|
+
if (node.type === AST_NODE_TYPES12.TSTypeAliasDeclaration && node.id.type === AST_NODE_TYPES12.Identifier) {
|
|
1017
1027
|
return { name: node.id.name, position: node.range[0] };
|
|
1018
1028
|
}
|
|
1019
1029
|
return null;
|
|
@@ -1049,7 +1059,7 @@ var enforceTypeDeclarationOrder = createRule11({
|
|
|
1049
1059
|
}
|
|
1050
1060
|
},
|
|
1051
1061
|
"TSPropertySignature TSTypeReference": function checkTypeReference(node) {
|
|
1052
|
-
if (node.typeName.type !==
|
|
1062
|
+
if (node.typeName.type !== AST_NODE_TYPES12.Identifier) {
|
|
1053
1063
|
return;
|
|
1054
1064
|
}
|
|
1055
1065
|
const referencedName = node.typeName.name;
|
|
@@ -1132,7 +1142,7 @@ var fileKebabCase = createRule12({
|
|
|
1132
1142
|
var file_kebab_case_default = fileKebabCase;
|
|
1133
1143
|
|
|
1134
1144
|
// src/rules/jsx-newline-between-elements.ts
|
|
1135
|
-
import { AST_NODE_TYPES as
|
|
1145
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES13, ESLintUtils as ESLintUtils13 } from "@typescript-eslint/utils";
|
|
1136
1146
|
var createRule13 = ESLintUtils13.RuleCreator(
|
|
1137
1147
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1138
1148
|
);
|
|
@@ -1154,7 +1164,7 @@ var jsxNewlineBetweenElements = createRule13({
|
|
|
1154
1164
|
create(context) {
|
|
1155
1165
|
const { sourceCode } = context;
|
|
1156
1166
|
function isSignificantJSXChild(node) {
|
|
1157
|
-
return node.type ===
|
|
1167
|
+
return node.type === AST_NODE_TYPES13.JSXElement || node.type === AST_NODE_TYPES13.JSXFragment || node.type === AST_NODE_TYPES13.JSXExpressionContainer;
|
|
1158
1168
|
}
|
|
1159
1169
|
function isMultiLine(node) {
|
|
1160
1170
|
return node.loc.start.line !== node.loc.end.line;
|
|
@@ -1204,7 +1214,7 @@ var jsxNewlineBetweenElements = createRule13({
|
|
|
1204
1214
|
var jsx_newline_between_elements_default = jsxNewlineBetweenElements;
|
|
1205
1215
|
|
|
1206
1216
|
// src/rules/jsx-no-inline-object-prop.ts
|
|
1207
|
-
import { AST_NODE_TYPES as
|
|
1217
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES14, ESLintUtils as ESLintUtils14 } from "@typescript-eslint/utils";
|
|
1208
1218
|
var createRule14 = ESLintUtils14.RuleCreator(
|
|
1209
1219
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1210
1220
|
);
|
|
@@ -1224,7 +1234,7 @@ var jsxNoInlineObjectProp = createRule14({
|
|
|
1224
1234
|
create(context) {
|
|
1225
1235
|
return {
|
|
1226
1236
|
JSXAttribute(node) {
|
|
1227
|
-
if (node.value?.type ===
|
|
1237
|
+
if (node.value?.type === AST_NODE_TYPES14.JSXExpressionContainer && node.value.expression.type === AST_NODE_TYPES14.ObjectExpression) {
|
|
1228
1238
|
context.report({
|
|
1229
1239
|
node: node.value,
|
|
1230
1240
|
messageId: "noInlineObject"
|
|
@@ -1237,12 +1247,12 @@ var jsxNoInlineObjectProp = createRule14({
|
|
|
1237
1247
|
var jsx_no_inline_object_prop_default = jsxNoInlineObjectProp;
|
|
1238
1248
|
|
|
1239
1249
|
// src/rules/jsx-no-newline-single-line-elements.ts
|
|
1240
|
-
import { AST_NODE_TYPES as
|
|
1250
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES15, ESLintUtils as ESLintUtils15 } from "@typescript-eslint/utils";
|
|
1241
1251
|
var createRule15 = ESLintUtils15.RuleCreator(
|
|
1242
1252
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1243
1253
|
);
|
|
1244
1254
|
function isJSXElementOrFragment(node) {
|
|
1245
|
-
return node.type ===
|
|
1255
|
+
return node.type === AST_NODE_TYPES15.JSXElement || node.type === AST_NODE_TYPES15.JSXFragment;
|
|
1246
1256
|
}
|
|
1247
1257
|
function isSingleLine(node) {
|
|
1248
1258
|
return node.loc.start.line === node.loc.end.line;
|
|
@@ -1265,7 +1275,7 @@ var jsxNoNewlineSingleLineElements = createRule15({
|
|
|
1265
1275
|
const { sourceCode } = context;
|
|
1266
1276
|
function checkSiblings(children) {
|
|
1267
1277
|
const nonWhitespace = children.filter(
|
|
1268
|
-
(child) => !(child.type ===
|
|
1278
|
+
(child) => !(child.type === AST_NODE_TYPES15.JSXText && child.value.trim() === "")
|
|
1269
1279
|
);
|
|
1270
1280
|
nonWhitespace.forEach((next, index) => {
|
|
1271
1281
|
if (index === 0) {
|
|
@@ -1317,13 +1327,6 @@ var jsx_no_newline_single_line_elements_default = jsxNoNewlineSingleLineElements
|
|
|
1317
1327
|
|
|
1318
1328
|
// src/rules/jsx-no-non-component-function.ts
|
|
1319
1329
|
import { AST_NODE_TYPES as AST_NODE_TYPES16, ESLintUtils as ESLintUtils16 } from "@typescript-eslint/utils";
|
|
1320
|
-
|
|
1321
|
-
// src/utils.ts
|
|
1322
|
-
import { basename, extname } from "path";
|
|
1323
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES15 } from "@typescript-eslint/utils";
|
|
1324
|
-
var getFileExtension = (filename) => extname(filename).slice(1);
|
|
1325
|
-
|
|
1326
|
-
// src/rules/jsx-no-non-component-function.ts
|
|
1327
1330
|
var createRule16 = ESLintUtils16.RuleCreator(
|
|
1328
1331
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1329
1332
|
);
|
|
@@ -4704,6 +4707,19 @@ var createConfig = (configRules) => ({
|
|
|
4704
4707
|
},
|
|
4705
4708
|
rules: configRules
|
|
4706
4709
|
});
|
|
4710
|
+
var NEXTJS_ROUTING_GLOBS = [
|
|
4711
|
+
"app/**/*.{jsx,tsx}",
|
|
4712
|
+
"src/app/**/*.{jsx,tsx}",
|
|
4713
|
+
"pages/**/*.{jsx,tsx}",
|
|
4714
|
+
"src/pages/**/*.{jsx,tsx}"
|
|
4715
|
+
];
|
|
4716
|
+
var nextjsRoutingOverride = {
|
|
4717
|
+
files: NEXTJS_ROUTING_GLOBS,
|
|
4718
|
+
rules: {
|
|
4719
|
+
"nextfriday/jsx-pascal-case": "off"
|
|
4720
|
+
}
|
|
4721
|
+
};
|
|
4722
|
+
var createNextjsConfig = (configRules) => [createConfig(configRules), nextjsRoutingOverride];
|
|
4707
4723
|
var configs = {
|
|
4708
4724
|
base: createConfig(baseRules),
|
|
4709
4725
|
"base/recommended": createConfig(baseRecommendedRules),
|
|
@@ -4715,55 +4731,16 @@ var configs = {
|
|
|
4715
4731
|
...baseRecommendedRules,
|
|
4716
4732
|
...jsxRecommendedRules
|
|
4717
4733
|
}),
|
|
4718
|
-
nextjs:
|
|
4734
|
+
nextjs: createNextjsConfig({
|
|
4719
4735
|
...baseRules,
|
|
4720
4736
|
...jsxRules,
|
|
4721
4737
|
...nextjsOnlyRules
|
|
4722
4738
|
}),
|
|
4723
|
-
"nextjs/recommended":
|
|
4739
|
+
"nextjs/recommended": createNextjsConfig({
|
|
4724
4740
|
...baseRecommendedRules,
|
|
4725
4741
|
...jsxRecommendedRules,
|
|
4726
4742
|
...nextjsOnlyRecommendedRules
|
|
4727
|
-
})
|
|
4728
|
-
get sonarjs() {
|
|
4729
|
-
const pluginSonarjs = rawSonarjs.default ?? rawSonarjs;
|
|
4730
|
-
const sonarjsRules = pluginSonarjs.configs.recommended.rules;
|
|
4731
|
-
return [
|
|
4732
|
-
{
|
|
4733
|
-
name: "sonarjs/config",
|
|
4734
|
-
plugins: {
|
|
4735
|
-
sonarjs: pluginSonarjs
|
|
4736
|
-
},
|
|
4737
|
-
rules: {
|
|
4738
|
-
...sonarjsRules
|
|
4739
|
-
}
|
|
4740
|
-
}
|
|
4741
|
-
];
|
|
4742
|
-
},
|
|
4743
|
-
get unicorn() {
|
|
4744
|
-
const pluginUnicorn = rawUnicorn.default ?? rawUnicorn;
|
|
4745
|
-
const unicornRules = pluginUnicorn.configs.recommended.rules;
|
|
4746
|
-
return [
|
|
4747
|
-
{
|
|
4748
|
-
name: "unicorn/config",
|
|
4749
|
-
plugins: {
|
|
4750
|
-
unicorn: pluginUnicorn
|
|
4751
|
-
},
|
|
4752
|
-
rules: {
|
|
4753
|
-
...unicornRules,
|
|
4754
|
-
"unicorn/filename-case": "off",
|
|
4755
|
-
"unicorn/prevent-abbreviations": "off"
|
|
4756
|
-
}
|
|
4757
|
-
},
|
|
4758
|
-
{
|
|
4759
|
-
name: "unicorn/jsx-tsx-exceptions",
|
|
4760
|
-
files: ["**/*.jsx", "**/*.tsx"],
|
|
4761
|
-
rules: {
|
|
4762
|
-
"unicorn/no-null": "off"
|
|
4763
|
-
}
|
|
4764
|
-
}
|
|
4765
|
-
];
|
|
4766
|
-
}
|
|
4743
|
+
})
|
|
4767
4744
|
};
|
|
4768
4745
|
var nextfridayPlugin = {
|
|
4769
4746
|
meta,
|