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