eslint-plugin-nextfriday 4.0.0 → 4.2.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 +17 -15
- package/docs/rules/ENFORCE_RENDER_NAMING.md +96 -0
- package/docs/rules/JSX_NO_DATA_ARRAY.md +63 -0
- package/docs/rules/JSX_NO_DATA_OBJECT.md +71 -0
- package/docs/rules/JSX_NO_SUB_INTERFACE.md +86 -0
- package/docs/rules/NO_GHOST_WRAPPER.md +75 -0
- package/docs/rules/NO_REDUNDANT_FRAGMENT.md +56 -0
- package/lib/index.cjs +1037 -442
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +252 -0
- package/lib/index.d.ts +252 -0
- package/lib/index.js +1037 -442
- package/lib/index.js.map +1 -1
- package/package.json +1 -1
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.
|
|
4
|
+
version: "4.2.0",
|
|
5
5
|
description: "A comprehensive ESLint plugin providing custom rules and configurations for Next Friday development workflows.",
|
|
6
6
|
keywords: [
|
|
7
7
|
"eslint",
|
|
@@ -765,18 +765,168 @@ var enforceReadonlyComponentProps = createRule7({
|
|
|
765
765
|
});
|
|
766
766
|
var enforce_readonly_component_props_default = enforceReadonlyComponentProps;
|
|
767
767
|
|
|
768
|
-
// src/rules/enforce-
|
|
768
|
+
// src/rules/enforce-render-naming.ts
|
|
769
769
|
import { AST_NODE_TYPES as AST_NODE_TYPES9, ESLintUtils as ESLintUtils8 } from "@typescript-eslint/utils";
|
|
770
770
|
var createRule8 = ESLintUtils8.RuleCreator(
|
|
771
771
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
772
772
|
);
|
|
773
|
+
var ARRAY_RETURNING_METHODS = /* @__PURE__ */ new Set(["map", "flatMap", "filter"]);
|
|
774
|
+
function hasRenderPrefix(name) {
|
|
775
|
+
if (!name.startsWith("render")) {
|
|
776
|
+
return false;
|
|
777
|
+
}
|
|
778
|
+
if (name.length === "render".length) {
|
|
779
|
+
return true;
|
|
780
|
+
}
|
|
781
|
+
const nextChar = name["render".length];
|
|
782
|
+
return nextChar === nextChar.toUpperCase() && nextChar !== nextChar.toLowerCase();
|
|
783
|
+
}
|
|
784
|
+
function functionBodyReturnsJsx(body) {
|
|
785
|
+
if (body.type === AST_NODE_TYPES9.JSXElement || body.type === AST_NODE_TYPES9.JSXFragment) {
|
|
786
|
+
return true;
|
|
787
|
+
}
|
|
788
|
+
if (body.type === AST_NODE_TYPES9.ConditionalExpression) {
|
|
789
|
+
return isJsxProducingExpression(body.consequent) || isJsxProducingExpression(body.alternate);
|
|
790
|
+
}
|
|
791
|
+
if (body.type === AST_NODE_TYPES9.LogicalExpression) {
|
|
792
|
+
return isJsxProducingExpression(body.right);
|
|
793
|
+
}
|
|
794
|
+
if (body.type !== AST_NODE_TYPES9.BlockStatement) {
|
|
795
|
+
return false;
|
|
796
|
+
}
|
|
797
|
+
for (const statement of body.body) {
|
|
798
|
+
if (statement.type === AST_NODE_TYPES9.ReturnStatement && statement.argument) {
|
|
799
|
+
if (isJsxProducingExpression(statement.argument)) {
|
|
800
|
+
return true;
|
|
801
|
+
}
|
|
802
|
+
}
|
|
803
|
+
}
|
|
804
|
+
return false;
|
|
805
|
+
}
|
|
806
|
+
function isJsxProducingExpression(node) {
|
|
807
|
+
if (node.type === AST_NODE_TYPES9.JSXElement || node.type === AST_NODE_TYPES9.JSXFragment) {
|
|
808
|
+
return true;
|
|
809
|
+
}
|
|
810
|
+
if (node.type === AST_NODE_TYPES9.ConditionalExpression) {
|
|
811
|
+
return isJsxProducingExpression(node.consequent) || isJsxProducingExpression(node.alternate);
|
|
812
|
+
}
|
|
813
|
+
if (node.type === AST_NODE_TYPES9.LogicalExpression) {
|
|
814
|
+
return isJsxProducingExpression(node.right);
|
|
815
|
+
}
|
|
816
|
+
if (node.type === AST_NODE_TYPES9.ArrayExpression) {
|
|
817
|
+
return node.elements.some((element) => {
|
|
818
|
+
if (!element || element.type === AST_NODE_TYPES9.SpreadElement) {
|
|
819
|
+
return false;
|
|
820
|
+
}
|
|
821
|
+
return isJsxProducingExpression(element);
|
|
822
|
+
});
|
|
823
|
+
}
|
|
824
|
+
if (node.type === AST_NODE_TYPES9.ArrowFunctionExpression || node.type === AST_NODE_TYPES9.FunctionExpression) {
|
|
825
|
+
return functionBodyReturnsJsx(node.body);
|
|
826
|
+
}
|
|
827
|
+
if (node.type === AST_NODE_TYPES9.CallExpression) {
|
|
828
|
+
if (node.callee.type === AST_NODE_TYPES9.MemberExpression && node.callee.property.type === AST_NODE_TYPES9.Identifier && ARRAY_RETURNING_METHODS.has(node.callee.property.name)) {
|
|
829
|
+
const callback = node.arguments[0];
|
|
830
|
+
if (callback && (callback.type === AST_NODE_TYPES9.ArrowFunctionExpression || callback.type === AST_NODE_TYPES9.FunctionExpression)) {
|
|
831
|
+
return functionBodyReturnsJsx(callback.body);
|
|
832
|
+
}
|
|
833
|
+
}
|
|
834
|
+
}
|
|
835
|
+
if (node.type === AST_NODE_TYPES9.TSAsExpression || node.type === AST_NODE_TYPES9.TSSatisfiesExpression) {
|
|
836
|
+
return isJsxProducingExpression(node.expression);
|
|
837
|
+
}
|
|
838
|
+
return false;
|
|
839
|
+
}
|
|
840
|
+
function isPascalCase(name) {
|
|
841
|
+
return /^[A-Z]/.test(name);
|
|
842
|
+
}
|
|
843
|
+
function isComponentFunction2(node) {
|
|
844
|
+
if (node.type === AST_NODE_TYPES9.FunctionDeclaration && node.id && isPascalCase(node.id.name)) {
|
|
845
|
+
return true;
|
|
846
|
+
}
|
|
847
|
+
const parent = node.parent;
|
|
848
|
+
if (parent?.type === AST_NODE_TYPES9.VariableDeclarator && parent.id.type === AST_NODE_TYPES9.Identifier && isPascalCase(parent.id.name)) {
|
|
849
|
+
return true;
|
|
850
|
+
}
|
|
851
|
+
return false;
|
|
852
|
+
}
|
|
853
|
+
var enforceRenderNaming = createRule8({
|
|
854
|
+
name: "enforce-render-naming",
|
|
855
|
+
meta: {
|
|
856
|
+
type: "problem",
|
|
857
|
+
docs: {
|
|
858
|
+
description: "Enforce 'render' prefix for variables that hold or return JSX inside React components"
|
|
859
|
+
},
|
|
860
|
+
schema: [],
|
|
861
|
+
messages: {
|
|
862
|
+
missingRenderPrefix: "Variable '{{ name }}' holds JSX-producing content inside a component. Rename it to 'render{{ pascalName }}' so the intent is explicit."
|
|
863
|
+
}
|
|
864
|
+
},
|
|
865
|
+
defaultOptions: [],
|
|
866
|
+
create(context) {
|
|
867
|
+
const { filename } = context;
|
|
868
|
+
const extension = getFileExtension(filename);
|
|
869
|
+
if (extension !== "tsx" && extension !== "jsx") {
|
|
870
|
+
return {};
|
|
871
|
+
}
|
|
872
|
+
const componentStack = [];
|
|
873
|
+
function isInsideComponent() {
|
|
874
|
+
return componentStack.some((value) => value);
|
|
875
|
+
}
|
|
876
|
+
function pushFunction(node) {
|
|
877
|
+
componentStack.push(isComponentFunction2(node));
|
|
878
|
+
}
|
|
879
|
+
function popFunction() {
|
|
880
|
+
componentStack.pop();
|
|
881
|
+
}
|
|
882
|
+
return {
|
|
883
|
+
ArrowFunctionExpression: pushFunction,
|
|
884
|
+
FunctionDeclaration: pushFunction,
|
|
885
|
+
FunctionExpression: pushFunction,
|
|
886
|
+
"ArrowFunctionExpression:exit": popFunction,
|
|
887
|
+
"FunctionDeclaration:exit": popFunction,
|
|
888
|
+
"FunctionExpression:exit": popFunction,
|
|
889
|
+
VariableDeclarator(node) {
|
|
890
|
+
if (!isInsideComponent()) {
|
|
891
|
+
return;
|
|
892
|
+
}
|
|
893
|
+
if (node.id.type !== AST_NODE_TYPES9.Identifier) {
|
|
894
|
+
return;
|
|
895
|
+
}
|
|
896
|
+
if (!node.init) {
|
|
897
|
+
return;
|
|
898
|
+
}
|
|
899
|
+
if (!isJsxProducingExpression(node.init)) {
|
|
900
|
+
return;
|
|
901
|
+
}
|
|
902
|
+
const name = node.id.name;
|
|
903
|
+
if (hasRenderPrefix(name)) {
|
|
904
|
+
return;
|
|
905
|
+
}
|
|
906
|
+
const pascalName = name.charAt(0).toUpperCase() + name.slice(1);
|
|
907
|
+
context.report({
|
|
908
|
+
node: node.id,
|
|
909
|
+
messageId: "missingRenderPrefix",
|
|
910
|
+
data: { name, pascalName }
|
|
911
|
+
});
|
|
912
|
+
}
|
|
913
|
+
};
|
|
914
|
+
}
|
|
915
|
+
});
|
|
916
|
+
var enforce_render_naming_default = enforceRenderNaming;
|
|
917
|
+
|
|
918
|
+
// src/rules/enforce-service-naming.ts
|
|
919
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES10, ESLintUtils as ESLintUtils9 } from "@typescript-eslint/utils";
|
|
920
|
+
var createRule9 = ESLintUtils9.RuleCreator(
|
|
921
|
+
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
922
|
+
);
|
|
773
923
|
var BANNED_PREFIXES = {
|
|
774
924
|
delete: ["remove", "archive"],
|
|
775
925
|
do: ["submit", "process"],
|
|
776
926
|
handle: ["create", "verify"],
|
|
777
927
|
set: ["update", "save", "patch"]
|
|
778
928
|
};
|
|
779
|
-
var enforceServiceNaming =
|
|
929
|
+
var enforceServiceNaming = createRule9({
|
|
780
930
|
name: "enforce-service-naming",
|
|
781
931
|
meta: {
|
|
782
932
|
type: "suggestion",
|
|
@@ -819,12 +969,12 @@ var enforceServiceNaming = createRule8({
|
|
|
819
969
|
};
|
|
820
970
|
return {
|
|
821
971
|
ExportNamedDeclaration(node) {
|
|
822
|
-
if (node.declaration?.type ===
|
|
972
|
+
if (node.declaration?.type === AST_NODE_TYPES10.FunctionDeclaration && node.declaration.id) {
|
|
823
973
|
checkExportedFunction(node.declaration, node.declaration.id);
|
|
824
974
|
}
|
|
825
|
-
if (node.declaration?.type ===
|
|
975
|
+
if (node.declaration?.type === AST_NODE_TYPES10.VariableDeclaration) {
|
|
826
976
|
node.declaration.declarations.forEach((declarator) => {
|
|
827
|
-
if (declarator.id.type ===
|
|
977
|
+
if (declarator.id.type === AST_NODE_TYPES10.Identifier && declarator.init?.type === AST_NODE_TYPES10.ArrowFunctionExpression) {
|
|
828
978
|
checkExportedFunction(declarator.init, declarator.id);
|
|
829
979
|
}
|
|
830
980
|
});
|
|
@@ -836,11 +986,11 @@ var enforceServiceNaming = createRule8({
|
|
|
836
986
|
var enforce_service_naming_default = enforceServiceNaming;
|
|
837
987
|
|
|
838
988
|
// src/rules/enforce-sorted-destructuring.ts
|
|
839
|
-
import { AST_NODE_TYPES as
|
|
840
|
-
var
|
|
989
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES11, ESLintUtils as ESLintUtils10 } from "@typescript-eslint/utils";
|
|
990
|
+
var createRule10 = ESLintUtils10.RuleCreator(
|
|
841
991
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
842
992
|
);
|
|
843
|
-
var enforceSortedDestructuring =
|
|
993
|
+
var enforceSortedDestructuring = createRule10({
|
|
844
994
|
name: "enforce-sorted-destructuring",
|
|
845
995
|
meta: {
|
|
846
996
|
type: "suggestion",
|
|
@@ -856,19 +1006,19 @@ var enforceSortedDestructuring = createRule9({
|
|
|
856
1006
|
defaultOptions: [],
|
|
857
1007
|
create(context) {
|
|
858
1008
|
function getPropertyName(property) {
|
|
859
|
-
if (property.type ===
|
|
1009
|
+
if (property.type === AST_NODE_TYPES11.RestElement) {
|
|
860
1010
|
return null;
|
|
861
1011
|
}
|
|
862
|
-
if (property.key.type ===
|
|
1012
|
+
if (property.key.type === AST_NODE_TYPES11.Identifier) {
|
|
863
1013
|
return property.key.name;
|
|
864
1014
|
}
|
|
865
1015
|
return null;
|
|
866
1016
|
}
|
|
867
1017
|
function hasDefaultValue(property) {
|
|
868
|
-
return property.value.type ===
|
|
1018
|
+
return property.value.type === AST_NODE_TYPES11.AssignmentPattern && Boolean(property.value.right);
|
|
869
1019
|
}
|
|
870
1020
|
function checkVariableDeclarator(node) {
|
|
871
|
-
if (node.id.type !==
|
|
1021
|
+
if (node.id.type !== AST_NODE_TYPES11.ObjectPattern) {
|
|
872
1022
|
return;
|
|
873
1023
|
}
|
|
874
1024
|
const { properties } = node.id;
|
|
@@ -876,7 +1026,7 @@ var enforceSortedDestructuring = createRule9({
|
|
|
876
1026
|
return;
|
|
877
1027
|
}
|
|
878
1028
|
const propertyInfo = properties.map((prop) => {
|
|
879
|
-
if (prop.type ===
|
|
1029
|
+
if (prop.type === AST_NODE_TYPES11.RestElement) {
|
|
880
1030
|
return null;
|
|
881
1031
|
}
|
|
882
1032
|
return {
|
|
@@ -915,20 +1065,20 @@ var enforceSortedDestructuring = createRule9({
|
|
|
915
1065
|
var enforce_sorted_destructuring_default = enforceSortedDestructuring;
|
|
916
1066
|
|
|
917
1067
|
// src/rules/enforce-type-declaration-order.ts
|
|
918
|
-
import { AST_NODE_TYPES as
|
|
919
|
-
var
|
|
1068
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES12, ESLintUtils as ESLintUtils11 } from "@typescript-eslint/utils";
|
|
1069
|
+
var createRule11 = ESLintUtils11.RuleCreator(
|
|
920
1070
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
921
1071
|
);
|
|
922
1072
|
function getTypeDeclarationName(node) {
|
|
923
|
-
if (node.type ===
|
|
1073
|
+
if (node.type === AST_NODE_TYPES12.TSInterfaceDeclaration && node.id.type === AST_NODE_TYPES12.Identifier) {
|
|
924
1074
|
return { name: node.id.name, position: node.range[0] };
|
|
925
1075
|
}
|
|
926
|
-
if (node.type ===
|
|
1076
|
+
if (node.type === AST_NODE_TYPES12.TSTypeAliasDeclaration && node.id.type === AST_NODE_TYPES12.Identifier) {
|
|
927
1077
|
return { name: node.id.name, position: node.range[0] };
|
|
928
1078
|
}
|
|
929
1079
|
return null;
|
|
930
1080
|
}
|
|
931
|
-
var enforceTypeDeclarationOrder =
|
|
1081
|
+
var enforceTypeDeclarationOrder = createRule11({
|
|
932
1082
|
name: "enforce-type-declaration-order",
|
|
933
1083
|
meta: {
|
|
934
1084
|
type: "suggestion",
|
|
@@ -959,7 +1109,7 @@ var enforceTypeDeclarationOrder = createRule10({
|
|
|
959
1109
|
}
|
|
960
1110
|
},
|
|
961
1111
|
"TSPropertySignature TSTypeReference": function checkTypeReference(node) {
|
|
962
|
-
if (node.typeName.type !==
|
|
1112
|
+
if (node.typeName.type !== AST_NODE_TYPES12.Identifier) {
|
|
963
1113
|
return;
|
|
964
1114
|
}
|
|
965
1115
|
const referencedName = node.typeName.name;
|
|
@@ -996,8 +1146,8 @@ var enforceTypeDeclarationOrder = createRule10({
|
|
|
996
1146
|
var enforce_type_declaration_order_default = enforceTypeDeclarationOrder;
|
|
997
1147
|
|
|
998
1148
|
// src/rules/index-export-only.ts
|
|
999
|
-
import { AST_NODE_TYPES as
|
|
1000
|
-
var
|
|
1149
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES13, ESLintUtils as ESLintUtils12 } from "@typescript-eslint/utils";
|
|
1150
|
+
var createRule12 = ESLintUtils12.RuleCreator(
|
|
1001
1151
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1002
1152
|
);
|
|
1003
1153
|
var isIndexFile = (filename) => getBaseName(filename) === "index";
|
|
@@ -1005,26 +1155,26 @@ var isAllowedExportNamed = (node) => {
|
|
|
1005
1155
|
if (!node.declaration) {
|
|
1006
1156
|
return true;
|
|
1007
1157
|
}
|
|
1008
|
-
return node.declaration.type ===
|
|
1158
|
+
return node.declaration.type === AST_NODE_TYPES13.TSTypeAliasDeclaration || node.declaration.type === AST_NODE_TYPES13.TSInterfaceDeclaration;
|
|
1009
1159
|
};
|
|
1010
|
-
var isAllowedExportDefault = (node) => node.declaration.type ===
|
|
1160
|
+
var isAllowedExportDefault = (node) => node.declaration.type === AST_NODE_TYPES13.Identifier;
|
|
1011
1161
|
var isAllowedTopLevel = (node) => {
|
|
1012
1162
|
switch (node.type) {
|
|
1013
|
-
case
|
|
1014
|
-
case
|
|
1015
|
-
case
|
|
1016
|
-
case
|
|
1017
|
-
case
|
|
1163
|
+
case AST_NODE_TYPES13.ImportDeclaration:
|
|
1164
|
+
case AST_NODE_TYPES13.ExportAllDeclaration:
|
|
1165
|
+
case AST_NODE_TYPES13.TSTypeAliasDeclaration:
|
|
1166
|
+
case AST_NODE_TYPES13.TSInterfaceDeclaration:
|
|
1167
|
+
case AST_NODE_TYPES13.TSImportEqualsDeclaration:
|
|
1018
1168
|
return true;
|
|
1019
|
-
case
|
|
1169
|
+
case AST_NODE_TYPES13.ExportNamedDeclaration:
|
|
1020
1170
|
return isAllowedExportNamed(node);
|
|
1021
|
-
case
|
|
1171
|
+
case AST_NODE_TYPES13.ExportDefaultDeclaration:
|
|
1022
1172
|
return isAllowedExportDefault(node);
|
|
1023
1173
|
default:
|
|
1024
1174
|
return false;
|
|
1025
1175
|
}
|
|
1026
1176
|
};
|
|
1027
|
-
var indexExportOnly =
|
|
1177
|
+
var indexExportOnly = createRule12({
|
|
1028
1178
|
name: "index-export-only",
|
|
1029
1179
|
meta: {
|
|
1030
1180
|
type: "suggestion",
|
|
@@ -1058,11 +1208,11 @@ var indexExportOnly = createRule11({
|
|
|
1058
1208
|
var index_export_only_default = indexExportOnly;
|
|
1059
1209
|
|
|
1060
1210
|
// src/rules/jsx-newline-between-elements.ts
|
|
1061
|
-
import { AST_NODE_TYPES as
|
|
1062
|
-
var
|
|
1211
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES14, ESLintUtils as ESLintUtils13 } from "@typescript-eslint/utils";
|
|
1212
|
+
var createRule13 = ESLintUtils13.RuleCreator(
|
|
1063
1213
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1064
1214
|
);
|
|
1065
|
-
var jsxNewlineBetweenElements =
|
|
1215
|
+
var jsxNewlineBetweenElements = createRule13({
|
|
1066
1216
|
name: "jsx-newline-between-elements",
|
|
1067
1217
|
meta: {
|
|
1068
1218
|
type: "layout",
|
|
@@ -1080,7 +1230,7 @@ var jsxNewlineBetweenElements = createRule12({
|
|
|
1080
1230
|
create(context) {
|
|
1081
1231
|
const { sourceCode } = context;
|
|
1082
1232
|
function isSignificantJSXChild(node) {
|
|
1083
|
-
return node.type ===
|
|
1233
|
+
return node.type === AST_NODE_TYPES14.JSXElement || node.type === AST_NODE_TYPES14.JSXFragment || node.type === AST_NODE_TYPES14.JSXExpressionContainer;
|
|
1084
1234
|
}
|
|
1085
1235
|
function isMultiLine(node) {
|
|
1086
1236
|
return node.loc.start.line !== node.loc.end.line;
|
|
@@ -1129,12 +1279,194 @@ var jsxNewlineBetweenElements = createRule12({
|
|
|
1129
1279
|
});
|
|
1130
1280
|
var jsx_newline_between_elements_default = jsxNewlineBetweenElements;
|
|
1131
1281
|
|
|
1282
|
+
// src/rules/jsx-no-data-array.ts
|
|
1283
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES15, ESLintUtils as ESLintUtils14 } from "@typescript-eslint/utils";
|
|
1284
|
+
var createRule14 = ESLintUtils14.RuleCreator(
|
|
1285
|
+
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1286
|
+
);
|
|
1287
|
+
function isObjectLikeElement(node) {
|
|
1288
|
+
if (!node) {
|
|
1289
|
+
return false;
|
|
1290
|
+
}
|
|
1291
|
+
if (node.type === AST_NODE_TYPES15.ObjectExpression) {
|
|
1292
|
+
return true;
|
|
1293
|
+
}
|
|
1294
|
+
if (node.type === AST_NODE_TYPES15.TSAsExpression || node.type === AST_NODE_TYPES15.TSSatisfiesExpression) {
|
|
1295
|
+
return isObjectLikeElement(node.expression);
|
|
1296
|
+
}
|
|
1297
|
+
return false;
|
|
1298
|
+
}
|
|
1299
|
+
function getArrayInitializer(init) {
|
|
1300
|
+
if (!init) {
|
|
1301
|
+
return null;
|
|
1302
|
+
}
|
|
1303
|
+
if (init.type === AST_NODE_TYPES15.ArrayExpression) {
|
|
1304
|
+
return init;
|
|
1305
|
+
}
|
|
1306
|
+
if (init.type === AST_NODE_TYPES15.TSAsExpression || init.type === AST_NODE_TYPES15.TSSatisfiesExpression) {
|
|
1307
|
+
return getArrayInitializer(init.expression);
|
|
1308
|
+
}
|
|
1309
|
+
return null;
|
|
1310
|
+
}
|
|
1311
|
+
var jsxNoDataArray = createRule14({
|
|
1312
|
+
name: "jsx-no-data-array",
|
|
1313
|
+
meta: {
|
|
1314
|
+
type: "problem",
|
|
1315
|
+
docs: {
|
|
1316
|
+
description: "Disallow top-level arrays of object literals in .tsx/.jsx files (extract to a data file)"
|
|
1317
|
+
},
|
|
1318
|
+
schema: [],
|
|
1319
|
+
messages: {
|
|
1320
|
+
noDataArray: "Top-level array of object literals belongs in a data file (e.g. *.data.ts), not a .tsx/.jsx component file. Extract '{{ name }}' to a sibling data module."
|
|
1321
|
+
}
|
|
1322
|
+
},
|
|
1323
|
+
defaultOptions: [],
|
|
1324
|
+
create(context) {
|
|
1325
|
+
const { filename } = context;
|
|
1326
|
+
const extension = getFileExtension(filename);
|
|
1327
|
+
if (extension !== "tsx" && extension !== "jsx") {
|
|
1328
|
+
return {};
|
|
1329
|
+
}
|
|
1330
|
+
return {
|
|
1331
|
+
"Program > VariableDeclaration > VariableDeclarator": function checkDeclarator(node) {
|
|
1332
|
+
const arrayInit = getArrayInitializer(node.init);
|
|
1333
|
+
if (!arrayInit) {
|
|
1334
|
+
return;
|
|
1335
|
+
}
|
|
1336
|
+
const hasObjectElement = arrayInit.elements.some((element) => isObjectLikeElement(element));
|
|
1337
|
+
if (!hasObjectElement) {
|
|
1338
|
+
return;
|
|
1339
|
+
}
|
|
1340
|
+
const name = node.id.type === AST_NODE_TYPES15.Identifier ? node.id.name : "<destructured>";
|
|
1341
|
+
context.report({
|
|
1342
|
+
node,
|
|
1343
|
+
messageId: "noDataArray",
|
|
1344
|
+
data: { name }
|
|
1345
|
+
});
|
|
1346
|
+
},
|
|
1347
|
+
"Program > ExportNamedDeclaration > VariableDeclaration > VariableDeclarator": function checkExportedDeclarator(node) {
|
|
1348
|
+
const arrayInit = getArrayInitializer(node.init);
|
|
1349
|
+
if (!arrayInit) {
|
|
1350
|
+
return;
|
|
1351
|
+
}
|
|
1352
|
+
const hasObjectElement = arrayInit.elements.some((element) => isObjectLikeElement(element));
|
|
1353
|
+
if (!hasObjectElement) {
|
|
1354
|
+
return;
|
|
1355
|
+
}
|
|
1356
|
+
const name = node.id.type === AST_NODE_TYPES15.Identifier ? node.id.name : "<destructured>";
|
|
1357
|
+
context.report({
|
|
1358
|
+
node,
|
|
1359
|
+
messageId: "noDataArray",
|
|
1360
|
+
data: { name }
|
|
1361
|
+
});
|
|
1362
|
+
}
|
|
1363
|
+
};
|
|
1364
|
+
}
|
|
1365
|
+
});
|
|
1366
|
+
var jsx_no_data_array_default = jsxNoDataArray;
|
|
1367
|
+
|
|
1368
|
+
// src/rules/jsx-no-data-object.ts
|
|
1369
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES16, ESLintUtils as ESLintUtils15 } from "@typescript-eslint/utils";
|
|
1370
|
+
var createRule15 = ESLintUtils15.RuleCreator(
|
|
1371
|
+
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1372
|
+
);
|
|
1373
|
+
function unwrapAssertion(node) {
|
|
1374
|
+
if (!node) {
|
|
1375
|
+
return null;
|
|
1376
|
+
}
|
|
1377
|
+
if (node.type === AST_NODE_TYPES16.TSAsExpression || node.type === AST_NODE_TYPES16.TSSatisfiesExpression) {
|
|
1378
|
+
return unwrapAssertion(node.expression);
|
|
1379
|
+
}
|
|
1380
|
+
return node;
|
|
1381
|
+
}
|
|
1382
|
+
function isNestedValue(value) {
|
|
1383
|
+
const unwrapped = unwrapAssertion(value);
|
|
1384
|
+
if (!unwrapped) {
|
|
1385
|
+
return false;
|
|
1386
|
+
}
|
|
1387
|
+
if (unwrapped.type === AST_NODE_TYPES16.ObjectExpression) {
|
|
1388
|
+
return true;
|
|
1389
|
+
}
|
|
1390
|
+
if (unwrapped.type === AST_NODE_TYPES16.ArrayExpression) {
|
|
1391
|
+
return unwrapped.elements.some((element) => {
|
|
1392
|
+
if (!element || element.type === AST_NODE_TYPES16.SpreadElement) {
|
|
1393
|
+
return false;
|
|
1394
|
+
}
|
|
1395
|
+
const inner = unwrapAssertion(element);
|
|
1396
|
+
return inner?.type === AST_NODE_TYPES16.ObjectExpression || inner?.type === AST_NODE_TYPES16.ArrayExpression;
|
|
1397
|
+
});
|
|
1398
|
+
}
|
|
1399
|
+
return false;
|
|
1400
|
+
}
|
|
1401
|
+
function hasNestedProperty(object) {
|
|
1402
|
+
return object.properties.some((property) => {
|
|
1403
|
+
if (property.type !== AST_NODE_TYPES16.Property) {
|
|
1404
|
+
return false;
|
|
1405
|
+
}
|
|
1406
|
+
if (property.value.type === AST_NODE_TYPES16.AssignmentPattern) {
|
|
1407
|
+
return false;
|
|
1408
|
+
}
|
|
1409
|
+
return isNestedValue(property.value);
|
|
1410
|
+
});
|
|
1411
|
+
}
|
|
1412
|
+
function getObjectInitializer(init) {
|
|
1413
|
+
const unwrapped = unwrapAssertion(init);
|
|
1414
|
+
if (!unwrapped) {
|
|
1415
|
+
return null;
|
|
1416
|
+
}
|
|
1417
|
+
if (unwrapped.type === AST_NODE_TYPES16.ObjectExpression) {
|
|
1418
|
+
return unwrapped;
|
|
1419
|
+
}
|
|
1420
|
+
return null;
|
|
1421
|
+
}
|
|
1422
|
+
var jsxNoDataObject = createRule15({
|
|
1423
|
+
name: "jsx-no-data-object",
|
|
1424
|
+
meta: {
|
|
1425
|
+
type: "problem",
|
|
1426
|
+
docs: {
|
|
1427
|
+
description: "Disallow top-level nested object literals in .tsx/.jsx files (extract to a data file)"
|
|
1428
|
+
},
|
|
1429
|
+
schema: [],
|
|
1430
|
+
messages: {
|
|
1431
|
+
noDataObject: "Top-level nested object literal belongs in a data file (e.g. *.data.ts), not a .tsx/.jsx component file. Extract '{{ name }}' to a sibling data module."
|
|
1432
|
+
}
|
|
1433
|
+
},
|
|
1434
|
+
defaultOptions: [],
|
|
1435
|
+
create(context) {
|
|
1436
|
+
const { filename } = context;
|
|
1437
|
+
const extension = getFileExtension(filename);
|
|
1438
|
+
if (extension !== "tsx" && extension !== "jsx") {
|
|
1439
|
+
return {};
|
|
1440
|
+
}
|
|
1441
|
+
function checkDeclarator(node) {
|
|
1442
|
+
const objectInit = getObjectInitializer(node.init);
|
|
1443
|
+
if (!objectInit) {
|
|
1444
|
+
return;
|
|
1445
|
+
}
|
|
1446
|
+
if (!hasNestedProperty(objectInit)) {
|
|
1447
|
+
return;
|
|
1448
|
+
}
|
|
1449
|
+
const name = node.id.type === AST_NODE_TYPES16.Identifier ? node.id.name : "<destructured>";
|
|
1450
|
+
context.report({
|
|
1451
|
+
node,
|
|
1452
|
+
messageId: "noDataObject",
|
|
1453
|
+
data: { name }
|
|
1454
|
+
});
|
|
1455
|
+
}
|
|
1456
|
+
return {
|
|
1457
|
+
"Program > VariableDeclaration > VariableDeclarator": checkDeclarator,
|
|
1458
|
+
"Program > ExportNamedDeclaration > VariableDeclaration > VariableDeclarator": checkDeclarator
|
|
1459
|
+
};
|
|
1460
|
+
}
|
|
1461
|
+
});
|
|
1462
|
+
var jsx_no_data_object_default = jsxNoDataObject;
|
|
1463
|
+
|
|
1132
1464
|
// src/rules/jsx-no-inline-object-prop.ts
|
|
1133
|
-
import { AST_NODE_TYPES as
|
|
1134
|
-
var
|
|
1465
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES17, ESLintUtils as ESLintUtils16 } from "@typescript-eslint/utils";
|
|
1466
|
+
var createRule16 = ESLintUtils16.RuleCreator(
|
|
1135
1467
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1136
1468
|
);
|
|
1137
|
-
var jsxNoInlineObjectProp =
|
|
1469
|
+
var jsxNoInlineObjectProp = createRule16({
|
|
1138
1470
|
name: "jsx-no-inline-object-prop",
|
|
1139
1471
|
meta: {
|
|
1140
1472
|
type: "suggestion",
|
|
@@ -1150,7 +1482,7 @@ var jsxNoInlineObjectProp = createRule13({
|
|
|
1150
1482
|
create(context) {
|
|
1151
1483
|
return {
|
|
1152
1484
|
JSXAttribute(node) {
|
|
1153
|
-
if (node.value?.type ===
|
|
1485
|
+
if (node.value?.type === AST_NODE_TYPES17.JSXExpressionContainer && node.value.expression.type === AST_NODE_TYPES17.ObjectExpression) {
|
|
1154
1486
|
context.report({
|
|
1155
1487
|
node: node.value,
|
|
1156
1488
|
messageId: "noInlineObject"
|
|
@@ -1163,17 +1495,17 @@ var jsxNoInlineObjectProp = createRule13({
|
|
|
1163
1495
|
var jsx_no_inline_object_prop_default = jsxNoInlineObjectProp;
|
|
1164
1496
|
|
|
1165
1497
|
// src/rules/jsx-no-newline-single-line-elements.ts
|
|
1166
|
-
import { AST_NODE_TYPES as
|
|
1167
|
-
var
|
|
1498
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES18, ESLintUtils as ESLintUtils17 } from "@typescript-eslint/utils";
|
|
1499
|
+
var createRule17 = ESLintUtils17.RuleCreator(
|
|
1168
1500
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1169
1501
|
);
|
|
1170
1502
|
function isJSXElementOrFragment(node) {
|
|
1171
|
-
return node.type ===
|
|
1503
|
+
return node.type === AST_NODE_TYPES18.JSXElement || node.type === AST_NODE_TYPES18.JSXFragment;
|
|
1172
1504
|
}
|
|
1173
1505
|
function isSingleLine(node) {
|
|
1174
1506
|
return node.loc.start.line === node.loc.end.line;
|
|
1175
1507
|
}
|
|
1176
|
-
var jsxNoNewlineSingleLineElements =
|
|
1508
|
+
var jsxNoNewlineSingleLineElements = createRule17({
|
|
1177
1509
|
name: "jsx-no-newline-single-line-elements",
|
|
1178
1510
|
meta: {
|
|
1179
1511
|
type: "layout",
|
|
@@ -1191,7 +1523,7 @@ var jsxNoNewlineSingleLineElements = createRule14({
|
|
|
1191
1523
|
const { sourceCode } = context;
|
|
1192
1524
|
function checkSiblings(children) {
|
|
1193
1525
|
const nonWhitespace = children.filter(
|
|
1194
|
-
(child) => !(child.type ===
|
|
1526
|
+
(child) => !(child.type === AST_NODE_TYPES18.JSXText && child.value.trim() === "")
|
|
1195
1527
|
);
|
|
1196
1528
|
nonWhitespace.forEach((next, index) => {
|
|
1197
1529
|
if (index === 0) {
|
|
@@ -1242,11 +1574,11 @@ ${indent}`);
|
|
|
1242
1574
|
var jsx_no_newline_single_line_elements_default = jsxNoNewlineSingleLineElements;
|
|
1243
1575
|
|
|
1244
1576
|
// src/rules/jsx-no-non-component-function.ts
|
|
1245
|
-
import { AST_NODE_TYPES as
|
|
1246
|
-
var
|
|
1577
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES19, ESLintUtils as ESLintUtils18 } from "@typescript-eslint/utils";
|
|
1578
|
+
var createRule18 = ESLintUtils18.RuleCreator(
|
|
1247
1579
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1248
1580
|
);
|
|
1249
|
-
var jsxNoNonComponentFunction =
|
|
1581
|
+
var jsxNoNonComponentFunction = createRule18({
|
|
1250
1582
|
name: "jsx-no-non-component-function",
|
|
1251
1583
|
meta: {
|
|
1252
1584
|
type: "problem",
|
|
@@ -1266,13 +1598,13 @@ var jsxNoNonComponentFunction = createRule15({
|
|
|
1266
1598
|
return {};
|
|
1267
1599
|
}
|
|
1268
1600
|
function isReactComponent2(node) {
|
|
1269
|
-
const functionName = node.type ===
|
|
1601
|
+
const functionName = node.type === AST_NODE_TYPES19.FunctionDeclaration && node.id ? node.id.name : null;
|
|
1270
1602
|
if (functionName && /^[A-Z]/.test(functionName)) {
|
|
1271
1603
|
return true;
|
|
1272
1604
|
}
|
|
1273
1605
|
if (node.returnType?.typeAnnotation) {
|
|
1274
1606
|
const returnTypeNode = node.returnType.typeAnnotation;
|
|
1275
|
-
if (returnTypeNode.type ===
|
|
1607
|
+
if (returnTypeNode.type === AST_NODE_TYPES19.TSTypeReference && returnTypeNode.typeName.type === AST_NODE_TYPES19.Identifier) {
|
|
1276
1608
|
const typeName = returnTypeNode.typeName.name;
|
|
1277
1609
|
if (typeName === "JSX" || typeName === "ReactElement" || typeName === "ReactNode") {
|
|
1278
1610
|
return true;
|
|
@@ -1289,13 +1621,13 @@ var jsxNoNonComponentFunction = createRule15({
|
|
|
1289
1621
|
if (!parent) {
|
|
1290
1622
|
return;
|
|
1291
1623
|
}
|
|
1292
|
-
if (parent.type ===
|
|
1624
|
+
if (parent.type === AST_NODE_TYPES19.ExportDefaultDeclaration || parent.type === AST_NODE_TYPES19.ExportNamedDeclaration) {
|
|
1293
1625
|
return;
|
|
1294
1626
|
}
|
|
1295
|
-
if (declaratorNode?.parent?.parent?.type ===
|
|
1627
|
+
if (declaratorNode?.parent?.parent?.type === AST_NODE_TYPES19.ExportNamedDeclaration) {
|
|
1296
1628
|
return;
|
|
1297
1629
|
}
|
|
1298
|
-
if (declaratorNode?.id.type ===
|
|
1630
|
+
if (declaratorNode?.id.type === AST_NODE_TYPES19.Identifier) {
|
|
1299
1631
|
const varName = declaratorNode.id.name;
|
|
1300
1632
|
if (/^[A-Z]/.test(varName)) {
|
|
1301
1633
|
return;
|
|
@@ -1319,21 +1651,146 @@ var jsxNoNonComponentFunction = createRule15({
|
|
|
1319
1651
|
});
|
|
1320
1652
|
var jsx_no_non_component_function_default = jsxNoNonComponentFunction;
|
|
1321
1653
|
|
|
1654
|
+
// src/rules/jsx-no-sub-interface.ts
|
|
1655
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES20, ESLintUtils as ESLintUtils19 } from "@typescript-eslint/utils";
|
|
1656
|
+
var createRule19 = ESLintUtils19.RuleCreator(
|
|
1657
|
+
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1658
|
+
);
|
|
1659
|
+
var PROPS_WRAPPER_NAMES = /* @__PURE__ */ new Set(["Readonly", "Required", "Partial", "PropsWithChildren", "NoInfer"]);
|
|
1660
|
+
function unwrapWrapperType(node) {
|
|
1661
|
+
if (node.type === AST_NODE_TYPES20.TSTypeReference && node.typeName.type === AST_NODE_TYPES20.Identifier && PROPS_WRAPPER_NAMES.has(node.typeName.name) && node.typeArguments && node.typeArguments.params.length > 0) {
|
|
1662
|
+
return unwrapWrapperType(node.typeArguments.params[0]);
|
|
1663
|
+
}
|
|
1664
|
+
return node;
|
|
1665
|
+
}
|
|
1666
|
+
function getMainTypeName(typeNode) {
|
|
1667
|
+
if (!typeNode) {
|
|
1668
|
+
return null;
|
|
1669
|
+
}
|
|
1670
|
+
const unwrapped = unwrapWrapperType(typeNode);
|
|
1671
|
+
if (unwrapped.type === AST_NODE_TYPES20.TSTypeReference && unwrapped.typeName.type === AST_NODE_TYPES20.Identifier) {
|
|
1672
|
+
return unwrapped.typeName.name;
|
|
1673
|
+
}
|
|
1674
|
+
return null;
|
|
1675
|
+
}
|
|
1676
|
+
function getComponentMainTypeName(node) {
|
|
1677
|
+
const firstParam = node.params[0];
|
|
1678
|
+
if (!firstParam) {
|
|
1679
|
+
return null;
|
|
1680
|
+
}
|
|
1681
|
+
if ("typeAnnotation" in firstParam && firstParam.typeAnnotation) {
|
|
1682
|
+
return getMainTypeName(firstParam.typeAnnotation.typeAnnotation);
|
|
1683
|
+
}
|
|
1684
|
+
return null;
|
|
1685
|
+
}
|
|
1686
|
+
function isPascalCase2(name) {
|
|
1687
|
+
return /^[A-Z]/.test(name);
|
|
1688
|
+
}
|
|
1689
|
+
function getDeclarationFromExportWrapper(node) {
|
|
1690
|
+
if (node.type === AST_NODE_TYPES20.ExportNamedDeclaration && node.declaration) {
|
|
1691
|
+
return node.declaration;
|
|
1692
|
+
}
|
|
1693
|
+
if (node.type === AST_NODE_TYPES20.ExportDefaultDeclaration) {
|
|
1694
|
+
return node.declaration;
|
|
1695
|
+
}
|
|
1696
|
+
return node;
|
|
1697
|
+
}
|
|
1698
|
+
var jsxNoSubInterface = createRule19({
|
|
1699
|
+
name: "jsx-no-sub-interface",
|
|
1700
|
+
meta: {
|
|
1701
|
+
type: "problem",
|
|
1702
|
+
docs: {
|
|
1703
|
+
description: "Disallow sub-interfaces and helper types in component files; keep only the main component props (extract the rest)"
|
|
1704
|
+
},
|
|
1705
|
+
schema: [],
|
|
1706
|
+
messages: {
|
|
1707
|
+
noSubInterface: "Sub-interface or helper type '{{ name }}' should not live in a component file. Extract it to a sibling module (e.g., a *.types.ts file or its own component file)."
|
|
1708
|
+
}
|
|
1709
|
+
},
|
|
1710
|
+
defaultOptions: [],
|
|
1711
|
+
create(context) {
|
|
1712
|
+
const { filename } = context;
|
|
1713
|
+
const extension = getFileExtension(filename);
|
|
1714
|
+
if (extension !== "tsx" && extension !== "jsx") {
|
|
1715
|
+
return {};
|
|
1716
|
+
}
|
|
1717
|
+
return {
|
|
1718
|
+
Program(programNode) {
|
|
1719
|
+
const mainTypes = /* @__PURE__ */ new Set();
|
|
1720
|
+
const typeDeclarations = [];
|
|
1721
|
+
let componentCount = 0;
|
|
1722
|
+
for (const statement of programNode.body) {
|
|
1723
|
+
const declaration = getDeclarationFromExportWrapper(statement);
|
|
1724
|
+
if (declaration.type === AST_NODE_TYPES20.FunctionDeclaration && declaration.id && isPascalCase2(declaration.id.name)) {
|
|
1725
|
+
componentCount += 1;
|
|
1726
|
+
const mainType = getComponentMainTypeName(declaration);
|
|
1727
|
+
if (mainType) {
|
|
1728
|
+
mainTypes.add(mainType);
|
|
1729
|
+
}
|
|
1730
|
+
continue;
|
|
1731
|
+
}
|
|
1732
|
+
if (declaration.type === AST_NODE_TYPES20.VariableDeclaration) {
|
|
1733
|
+
for (const declarator of declaration.declarations) {
|
|
1734
|
+
if (declarator.id.type !== AST_NODE_TYPES20.Identifier) {
|
|
1735
|
+
continue;
|
|
1736
|
+
}
|
|
1737
|
+
if (!isPascalCase2(declarator.id.name)) {
|
|
1738
|
+
continue;
|
|
1739
|
+
}
|
|
1740
|
+
const init = declarator.init;
|
|
1741
|
+
if (init && (init.type === AST_NODE_TYPES20.ArrowFunctionExpression || init.type === AST_NODE_TYPES20.FunctionExpression)) {
|
|
1742
|
+
componentCount += 1;
|
|
1743
|
+
const mainType = getComponentMainTypeName(init);
|
|
1744
|
+
if (mainType) {
|
|
1745
|
+
mainTypes.add(mainType);
|
|
1746
|
+
}
|
|
1747
|
+
}
|
|
1748
|
+
}
|
|
1749
|
+
continue;
|
|
1750
|
+
}
|
|
1751
|
+
if (declaration.type === AST_NODE_TYPES20.TSInterfaceDeclaration) {
|
|
1752
|
+
typeDeclarations.push({ name: declaration.id.name, node: declaration });
|
|
1753
|
+
continue;
|
|
1754
|
+
}
|
|
1755
|
+
if (declaration.type === AST_NODE_TYPES20.TSTypeAliasDeclaration) {
|
|
1756
|
+
typeDeclarations.push({ name: declaration.id.name, node: declaration });
|
|
1757
|
+
continue;
|
|
1758
|
+
}
|
|
1759
|
+
}
|
|
1760
|
+
if (componentCount === 0) {
|
|
1761
|
+
return;
|
|
1762
|
+
}
|
|
1763
|
+
for (const declaration of typeDeclarations) {
|
|
1764
|
+
if (mainTypes.has(declaration.name)) {
|
|
1765
|
+
continue;
|
|
1766
|
+
}
|
|
1767
|
+
context.report({
|
|
1768
|
+
node: declaration.node,
|
|
1769
|
+
messageId: "noSubInterface",
|
|
1770
|
+
data: { name: declaration.name }
|
|
1771
|
+
});
|
|
1772
|
+
}
|
|
1773
|
+
}
|
|
1774
|
+
};
|
|
1775
|
+
}
|
|
1776
|
+
});
|
|
1777
|
+
var jsx_no_sub_interface_default = jsxNoSubInterface;
|
|
1778
|
+
|
|
1322
1779
|
// src/rules/jsx-no-ternary-null.ts
|
|
1323
|
-
import { AST_NODE_TYPES as
|
|
1324
|
-
var
|
|
1780
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES21, ESLintUtils as ESLintUtils20 } from "@typescript-eslint/utils";
|
|
1781
|
+
var createRule20 = ESLintUtils20.RuleCreator(
|
|
1325
1782
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1326
1783
|
);
|
|
1327
1784
|
function isNullOrUndefined(node) {
|
|
1328
|
-
if (node.type ===
|
|
1785
|
+
if (node.type === AST_NODE_TYPES21.Literal && node.value === null) {
|
|
1329
1786
|
return true;
|
|
1330
1787
|
}
|
|
1331
|
-
if (node.type ===
|
|
1788
|
+
if (node.type === AST_NODE_TYPES21.Identifier && node.name === "undefined") {
|
|
1332
1789
|
return true;
|
|
1333
1790
|
}
|
|
1334
1791
|
return false;
|
|
1335
1792
|
}
|
|
1336
|
-
var jsxNoTernaryNull =
|
|
1793
|
+
var jsxNoTernaryNull = createRule20({
|
|
1337
1794
|
name: "jsx-no-ternary-null",
|
|
1338
1795
|
meta: {
|
|
1339
1796
|
type: "suggestion",
|
|
@@ -1351,7 +1808,7 @@ var jsxNoTernaryNull = createRule16({
|
|
|
1351
1808
|
return {
|
|
1352
1809
|
JSXExpressionContainer(node) {
|
|
1353
1810
|
const { expression } = node;
|
|
1354
|
-
if (expression.type !==
|
|
1811
|
+
if (expression.type !== AST_NODE_TYPES21.ConditionalExpression) {
|
|
1355
1812
|
return;
|
|
1356
1813
|
}
|
|
1357
1814
|
const { test, consequent, alternate } = expression;
|
|
@@ -1383,11 +1840,11 @@ var jsxNoTernaryNull = createRule16({
|
|
|
1383
1840
|
var jsx_no_ternary_null_default = jsxNoTernaryNull;
|
|
1384
1841
|
|
|
1385
1842
|
// src/rules/jsx-no-variable-in-callback.ts
|
|
1386
|
-
import { AST_NODE_TYPES as
|
|
1387
|
-
var
|
|
1843
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES22, ESLintUtils as ESLintUtils21 } from "@typescript-eslint/utils";
|
|
1844
|
+
var createRule21 = ESLintUtils21.RuleCreator(
|
|
1388
1845
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1389
1846
|
);
|
|
1390
|
-
var jsxNoVariableInCallback =
|
|
1847
|
+
var jsxNoVariableInCallback = createRule21({
|
|
1391
1848
|
name: "jsx-no-variable-in-callback",
|
|
1392
1849
|
meta: {
|
|
1393
1850
|
type: "suggestion",
|
|
@@ -1404,7 +1861,7 @@ var jsxNoVariableInCallback = createRule17({
|
|
|
1404
1861
|
function isInsideJSX(node) {
|
|
1405
1862
|
let current = node.parent;
|
|
1406
1863
|
while (current) {
|
|
1407
|
-
if (current.type ===
|
|
1864
|
+
if (current.type === AST_NODE_TYPES22.JSXElement || current.type === AST_NODE_TYPES22.JSXFragment) {
|
|
1408
1865
|
return true;
|
|
1409
1866
|
}
|
|
1410
1867
|
current = current.parent;
|
|
@@ -1418,11 +1875,11 @@ var jsxNoVariableInCallback = createRule17({
|
|
|
1418
1875
|
if (!isInsideJSX(node)) {
|
|
1419
1876
|
return false;
|
|
1420
1877
|
}
|
|
1421
|
-
if (node.parent.type ===
|
|
1878
|
+
if (node.parent.type === AST_NODE_TYPES22.CallExpression || node.parent.type === AST_NODE_TYPES22.JSXExpressionContainer) {
|
|
1422
1879
|
return true;
|
|
1423
1880
|
}
|
|
1424
|
-
if (node.parent.type ===
|
|
1425
|
-
if (node.parent.parent.type ===
|
|
1881
|
+
if (node.parent.type === AST_NODE_TYPES22.ArrayExpression && node.parent.parent) {
|
|
1882
|
+
if (node.parent.parent.type === AST_NODE_TYPES22.CallExpression || node.parent.parent.type === AST_NODE_TYPES22.JSXExpressionContainer) {
|
|
1426
1883
|
return true;
|
|
1427
1884
|
}
|
|
1428
1885
|
}
|
|
@@ -1433,11 +1890,11 @@ var jsxNoVariableInCallback = createRule17({
|
|
|
1433
1890
|
return;
|
|
1434
1891
|
}
|
|
1435
1892
|
const { body } = node;
|
|
1436
|
-
if (body.type !==
|
|
1893
|
+
if (body.type !== AST_NODE_TYPES22.BlockStatement) {
|
|
1437
1894
|
return;
|
|
1438
1895
|
}
|
|
1439
1896
|
body.body.forEach((statement) => {
|
|
1440
|
-
if (statement.type ===
|
|
1897
|
+
if (statement.type === AST_NODE_TYPES22.VariableDeclaration) {
|
|
1441
1898
|
context.report({
|
|
1442
1899
|
node: statement,
|
|
1443
1900
|
messageId: "noVariableInCallback"
|
|
@@ -1454,11 +1911,11 @@ var jsxNoVariableInCallback = createRule17({
|
|
|
1454
1911
|
var jsx_no_variable_in_callback_default = jsxNoVariableInCallback;
|
|
1455
1912
|
|
|
1456
1913
|
// src/rules/jsx-require-suspense.ts
|
|
1457
|
-
import { AST_NODE_TYPES as
|
|
1458
|
-
var
|
|
1914
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES23, ESLintUtils as ESLintUtils22 } from "@typescript-eslint/utils";
|
|
1915
|
+
var createRule22 = ESLintUtils22.RuleCreator(
|
|
1459
1916
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1460
1917
|
);
|
|
1461
|
-
var jsxRequireSuspense =
|
|
1918
|
+
var jsxRequireSuspense = createRule22({
|
|
1462
1919
|
name: "jsx-require-suspense",
|
|
1463
1920
|
meta: {
|
|
1464
1921
|
type: "problem",
|
|
@@ -1476,7 +1933,7 @@ var jsxRequireSuspense = createRule18({
|
|
|
1476
1933
|
const isInsideSuspense = (node) => {
|
|
1477
1934
|
let current = node.parent;
|
|
1478
1935
|
while (current) {
|
|
1479
|
-
if (current.type ===
|
|
1936
|
+
if (current.type === AST_NODE_TYPES23.JSXElement && current.openingElement.name.type === AST_NODE_TYPES23.JSXIdentifier && current.openingElement.name.name === "Suspense") {
|
|
1480
1937
|
return true;
|
|
1481
1938
|
}
|
|
1482
1939
|
current = current.parent;
|
|
@@ -1485,16 +1942,16 @@ var jsxRequireSuspense = createRule18({
|
|
|
1485
1942
|
};
|
|
1486
1943
|
return {
|
|
1487
1944
|
VariableDeclarator(node) {
|
|
1488
|
-
if (node.id.type ===
|
|
1945
|
+
if (node.id.type === AST_NODE_TYPES23.Identifier && node.init?.type === AST_NODE_TYPES23.CallExpression) {
|
|
1489
1946
|
const { callee } = node.init;
|
|
1490
|
-
const isLazyCall = callee.type ===
|
|
1947
|
+
const isLazyCall = callee.type === AST_NODE_TYPES23.Identifier && callee.name === "lazy" || callee.type === AST_NODE_TYPES23.MemberExpression && callee.object.type === AST_NODE_TYPES23.Identifier && callee.object.name === "React" && callee.property.type === AST_NODE_TYPES23.Identifier && callee.property.name === "lazy";
|
|
1491
1948
|
if (isLazyCall) {
|
|
1492
1949
|
lazyComponents.add(node.id.name);
|
|
1493
1950
|
}
|
|
1494
1951
|
}
|
|
1495
1952
|
},
|
|
1496
1953
|
JSXOpeningElement(node) {
|
|
1497
|
-
if (node.name.type ===
|
|
1954
|
+
if (node.name.type === AST_NODE_TYPES23.JSXIdentifier) {
|
|
1498
1955
|
const componentName = node.name.name;
|
|
1499
1956
|
if (lazyComponents.has(componentName) && !isInsideSuspense(node)) {
|
|
1500
1957
|
context.report({
|
|
@@ -1513,11 +1970,11 @@ var jsxRequireSuspense = createRule18({
|
|
|
1513
1970
|
var jsx_require_suspense_default = jsxRequireSuspense;
|
|
1514
1971
|
|
|
1515
1972
|
// src/rules/jsx-simple-props.ts
|
|
1516
|
-
import { AST_NODE_TYPES as
|
|
1517
|
-
var
|
|
1973
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES24, ESLintUtils as ESLintUtils23 } from "@typescript-eslint/utils";
|
|
1974
|
+
var createRule23 = ESLintUtils23.RuleCreator(
|
|
1518
1975
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1519
1976
|
);
|
|
1520
|
-
var jsxSimpleProps =
|
|
1977
|
+
var jsxSimpleProps = createRule23({
|
|
1521
1978
|
name: "jsx-simple-props",
|
|
1522
1979
|
meta: {
|
|
1523
1980
|
type: "suggestion",
|
|
@@ -1532,25 +1989,25 @@ var jsxSimpleProps = createRule19({
|
|
|
1532
1989
|
defaultOptions: [],
|
|
1533
1990
|
create(context) {
|
|
1534
1991
|
const allowedExpressionTypes = /* @__PURE__ */ new Set([
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1992
|
+
AST_NODE_TYPES24.Identifier,
|
|
1993
|
+
AST_NODE_TYPES24.Literal,
|
|
1994
|
+
AST_NODE_TYPES24.JSXElement,
|
|
1995
|
+
AST_NODE_TYPES24.JSXFragment,
|
|
1996
|
+
AST_NODE_TYPES24.MemberExpression,
|
|
1997
|
+
AST_NODE_TYPES24.ArrowFunctionExpression,
|
|
1998
|
+
AST_NODE_TYPES24.FunctionExpression
|
|
1542
1999
|
]);
|
|
1543
2000
|
return {
|
|
1544
2001
|
JSXAttribute(node) {
|
|
1545
2002
|
if (!node.value) {
|
|
1546
2003
|
return;
|
|
1547
2004
|
}
|
|
1548
|
-
if (node.value.type ===
|
|
2005
|
+
if (node.value.type === AST_NODE_TYPES24.Literal) {
|
|
1549
2006
|
return;
|
|
1550
2007
|
}
|
|
1551
|
-
if (node.value.type ===
|
|
2008
|
+
if (node.value.type === AST_NODE_TYPES24.JSXExpressionContainer) {
|
|
1552
2009
|
const { expression } = node.value;
|
|
1553
|
-
if (expression.type ===
|
|
2010
|
+
if (expression.type === AST_NODE_TYPES24.JSXEmptyExpression) {
|
|
1554
2011
|
return;
|
|
1555
2012
|
}
|
|
1556
2013
|
if (!allowedExpressionTypes.has(expression.type)) {
|
|
@@ -1567,8 +2024,8 @@ var jsxSimpleProps = createRule19({
|
|
|
1567
2024
|
var jsx_simple_props_default = jsxSimpleProps;
|
|
1568
2025
|
|
|
1569
2026
|
// src/rules/jsx-sort-props.ts
|
|
1570
|
-
import { AST_NODE_TYPES as
|
|
1571
|
-
var
|
|
2027
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES25, ESLintUtils as ESLintUtils24 } from "@typescript-eslint/utils";
|
|
2028
|
+
var createRule24 = ESLintUtils24.RuleCreator(
|
|
1572
2029
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1573
2030
|
);
|
|
1574
2031
|
var TYPE_GROUP = {
|
|
@@ -1582,15 +2039,15 @@ var TYPE_GROUP = {
|
|
|
1582
2039
|
SHORTHAND: 8
|
|
1583
2040
|
};
|
|
1584
2041
|
var EXPRESSION_TYPE_TO_GROUP = /* @__PURE__ */ new Map([
|
|
1585
|
-
[
|
|
1586
|
-
[
|
|
1587
|
-
[
|
|
1588
|
-
[
|
|
1589
|
-
[
|
|
1590
|
-
[
|
|
2042
|
+
[AST_NODE_TYPES25.ObjectExpression, TYPE_GROUP.OBJECT_ARRAY],
|
|
2043
|
+
[AST_NODE_TYPES25.ArrayExpression, TYPE_GROUP.OBJECT_ARRAY],
|
|
2044
|
+
[AST_NODE_TYPES25.ArrowFunctionExpression, TYPE_GROUP.FUNCTION],
|
|
2045
|
+
[AST_NODE_TYPES25.FunctionExpression, TYPE_GROUP.FUNCTION],
|
|
2046
|
+
[AST_NODE_TYPES25.JSXElement, TYPE_GROUP.JSX],
|
|
2047
|
+
[AST_NODE_TYPES25.JSXFragment, TYPE_GROUP.JSX]
|
|
1591
2048
|
]);
|
|
1592
2049
|
function isHyphenatedName(node) {
|
|
1593
|
-
return node.name.type ===
|
|
2050
|
+
return node.name.type === AST_NODE_TYPES25.JSXIdentifier && node.name.name.includes("-");
|
|
1594
2051
|
}
|
|
1595
2052
|
function getStringGroup(node) {
|
|
1596
2053
|
return isHyphenatedName(node) ? TYPE_GROUP.HYPHENATED_STRING : TYPE_GROUP.STRING;
|
|
@@ -1602,13 +2059,13 @@ function getLiteralValueGroup(value) {
|
|
|
1602
2059
|
return TYPE_GROUP.NUMBER_BOOLEAN_NULL;
|
|
1603
2060
|
}
|
|
1604
2061
|
function getExpressionGroup(expression) {
|
|
1605
|
-
if (expression.type ===
|
|
2062
|
+
if (expression.type === AST_NODE_TYPES25.Literal) {
|
|
1606
2063
|
return getLiteralValueGroup(expression.value);
|
|
1607
2064
|
}
|
|
1608
|
-
if (expression.type ===
|
|
2065
|
+
if (expression.type === AST_NODE_TYPES25.TemplateLiteral) {
|
|
1609
2066
|
return null;
|
|
1610
2067
|
}
|
|
1611
|
-
if (expression.type ===
|
|
2068
|
+
if (expression.type === AST_NODE_TYPES25.Identifier && expression.name === "undefined") {
|
|
1612
2069
|
return TYPE_GROUP.NUMBER_BOOLEAN_NULL;
|
|
1613
2070
|
}
|
|
1614
2071
|
return EXPRESSION_TYPE_TO_GROUP.get(expression.type) ?? TYPE_GROUP.EXPRESSION;
|
|
@@ -1617,17 +2074,17 @@ function getTypeGroup(node) {
|
|
|
1617
2074
|
if (node.value === null) {
|
|
1618
2075
|
return TYPE_GROUP.SHORTHAND;
|
|
1619
2076
|
}
|
|
1620
|
-
if (node.value.type ===
|
|
2077
|
+
if (node.value.type === AST_NODE_TYPES25.Literal) {
|
|
1621
2078
|
if (typeof node.value.value === "string") {
|
|
1622
2079
|
return getStringGroup(node);
|
|
1623
2080
|
}
|
|
1624
2081
|
return TYPE_GROUP.NUMBER_BOOLEAN_NULL;
|
|
1625
2082
|
}
|
|
1626
|
-
if (node.value.type !==
|
|
2083
|
+
if (node.value.type !== AST_NODE_TYPES25.JSXExpressionContainer) {
|
|
1627
2084
|
return null;
|
|
1628
2085
|
}
|
|
1629
2086
|
const { expression } = node.value;
|
|
1630
|
-
if (expression.type ===
|
|
2087
|
+
if (expression.type === AST_NODE_TYPES25.JSXEmptyExpression) {
|
|
1631
2088
|
return null;
|
|
1632
2089
|
}
|
|
1633
2090
|
const group = getExpressionGroup(expression);
|
|
@@ -1639,7 +2096,7 @@ function getTypeGroup(node) {
|
|
|
1639
2096
|
function hasUnsortedProps(attributes) {
|
|
1640
2097
|
let lastGroup = 0;
|
|
1641
2098
|
return attributes.some((attribute) => {
|
|
1642
|
-
if (attribute.type ===
|
|
2099
|
+
if (attribute.type === AST_NODE_TYPES25.JSXSpreadAttribute) {
|
|
1643
2100
|
lastGroup = 0;
|
|
1644
2101
|
return false;
|
|
1645
2102
|
}
|
|
@@ -1663,7 +2120,7 @@ function getSegments(attributes) {
|
|
|
1663
2120
|
const result = [];
|
|
1664
2121
|
let current = [];
|
|
1665
2122
|
attributes.forEach((attr) => {
|
|
1666
|
-
if (attr.type ===
|
|
2123
|
+
if (attr.type === AST_NODE_TYPES25.JSXSpreadAttribute) {
|
|
1667
2124
|
if (current.length > 0) {
|
|
1668
2125
|
result.push(current);
|
|
1669
2126
|
current = [];
|
|
@@ -1677,7 +2134,7 @@ function getSegments(attributes) {
|
|
|
1677
2134
|
}
|
|
1678
2135
|
return result;
|
|
1679
2136
|
}
|
|
1680
|
-
var jsxSortProps =
|
|
2137
|
+
var jsxSortProps = createRule24({
|
|
1681
2138
|
name: "jsx-sort-props",
|
|
1682
2139
|
meta: {
|
|
1683
2140
|
type: "suggestion",
|
|
@@ -1712,11 +2169,11 @@ var jsxSortProps = createRule20({
|
|
|
1712
2169
|
var jsx_sort_props_default = jsxSortProps;
|
|
1713
2170
|
|
|
1714
2171
|
// src/rules/jsx-spread-props-last.ts
|
|
1715
|
-
import { AST_NODE_TYPES as
|
|
1716
|
-
var
|
|
2172
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES26, ESLintUtils as ESLintUtils25 } from "@typescript-eslint/utils";
|
|
2173
|
+
var createRule25 = ESLintUtils25.RuleCreator(
|
|
1717
2174
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1718
2175
|
);
|
|
1719
|
-
var jsxSpreadPropsLast =
|
|
2176
|
+
var jsxSpreadPropsLast = createRule25({
|
|
1720
2177
|
name: "jsx-spread-props-last",
|
|
1721
2178
|
meta: {
|
|
1722
2179
|
type: "suggestion",
|
|
@@ -1735,12 +2192,12 @@ var jsxSpreadPropsLast = createRule21({
|
|
|
1735
2192
|
const { attributes } = node;
|
|
1736
2193
|
let lastNonSpreadIndex = -1;
|
|
1737
2194
|
attributes.forEach((attribute, index) => {
|
|
1738
|
-
if (attribute.type !==
|
|
2195
|
+
if (attribute.type !== AST_NODE_TYPES26.JSXSpreadAttribute) {
|
|
1739
2196
|
lastNonSpreadIndex = index;
|
|
1740
2197
|
}
|
|
1741
2198
|
});
|
|
1742
2199
|
attributes.forEach((attribute, index) => {
|
|
1743
|
-
if (attribute.type ===
|
|
2200
|
+
if (attribute.type === AST_NODE_TYPES26.JSXSpreadAttribute && index < lastNonSpreadIndex) {
|
|
1744
2201
|
context.report({
|
|
1745
2202
|
node: attribute,
|
|
1746
2203
|
messageId: "spreadNotLast"
|
|
@@ -1754,12 +2211,12 @@ var jsxSpreadPropsLast = createRule21({
|
|
|
1754
2211
|
var jsx_spread_props_last_default = jsxSpreadPropsLast;
|
|
1755
2212
|
|
|
1756
2213
|
// src/rules/newline-after-multiline-block.ts
|
|
1757
|
-
import { AST_NODE_TYPES as
|
|
1758
|
-
var
|
|
2214
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES27, ESLintUtils as ESLintUtils26 } from "@typescript-eslint/utils";
|
|
2215
|
+
var createRule26 = ESLintUtils26.RuleCreator(
|
|
1759
2216
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1760
2217
|
);
|
|
1761
2218
|
function isImportDeclaration(node) {
|
|
1762
|
-
return node.type ===
|
|
2219
|
+
return node.type === AST_NODE_TYPES27.ImportDeclaration;
|
|
1763
2220
|
}
|
|
1764
2221
|
function checkStatements(statements, context) {
|
|
1765
2222
|
const { sourceCode } = context;
|
|
@@ -1794,7 +2251,7 @@ function checkStatements(statements, context) {
|
|
|
1794
2251
|
}
|
|
1795
2252
|
});
|
|
1796
2253
|
}
|
|
1797
|
-
var newlineAfterMultilineBlock =
|
|
2254
|
+
var newlineAfterMultilineBlock = createRule26({
|
|
1798
2255
|
name: "newline-after-multiline-block",
|
|
1799
2256
|
meta: {
|
|
1800
2257
|
type: "layout",
|
|
@@ -1822,11 +2279,11 @@ var newlineAfterMultilineBlock = createRule22({
|
|
|
1822
2279
|
var newline_after_multiline_block_default = newlineAfterMultilineBlock;
|
|
1823
2280
|
|
|
1824
2281
|
// src/rules/newline-before-return.ts
|
|
1825
|
-
import { AST_NODE_TYPES as
|
|
1826
|
-
var
|
|
2282
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES28, ESLintUtils as ESLintUtils27 } from "@typescript-eslint/utils";
|
|
2283
|
+
var createRule27 = ESLintUtils27.RuleCreator(
|
|
1827
2284
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1828
2285
|
);
|
|
1829
|
-
var newlineBeforeReturn =
|
|
2286
|
+
var newlineBeforeReturn = createRule27({
|
|
1830
2287
|
name: "newline-before-return",
|
|
1831
2288
|
meta: {
|
|
1832
2289
|
type: "layout",
|
|
@@ -1844,7 +2301,7 @@ var newlineBeforeReturn = createRule23({
|
|
|
1844
2301
|
const { sourceCode } = context;
|
|
1845
2302
|
function checkReturnStatement(node) {
|
|
1846
2303
|
const { parent } = node;
|
|
1847
|
-
if (!parent || parent.type !==
|
|
2304
|
+
if (!parent || parent.type !== AST_NODE_TYPES28.BlockStatement) {
|
|
1848
2305
|
return;
|
|
1849
2306
|
}
|
|
1850
2307
|
const { body: statements } = parent;
|
|
@@ -1881,11 +2338,11 @@ var newlineBeforeReturn = createRule23({
|
|
|
1881
2338
|
var newline_before_return_default = newlineBeforeReturn;
|
|
1882
2339
|
|
|
1883
2340
|
// src/rules/no-complex-inline-return.ts
|
|
1884
|
-
import { AST_NODE_TYPES as
|
|
1885
|
-
var
|
|
2341
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES29, ESLintUtils as ESLintUtils28 } from "@typescript-eslint/utils";
|
|
2342
|
+
var createRule28 = ESLintUtils28.RuleCreator(
|
|
1886
2343
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1887
2344
|
);
|
|
1888
|
-
var noComplexInlineReturn =
|
|
2345
|
+
var noComplexInlineReturn = createRule28({
|
|
1889
2346
|
name: "no-complex-inline-return",
|
|
1890
2347
|
meta: {
|
|
1891
2348
|
type: "suggestion",
|
|
@@ -1901,13 +2358,13 @@ var noComplexInlineReturn = createRule24({
|
|
|
1901
2358
|
create(context) {
|
|
1902
2359
|
const isComplexExpression = (node) => {
|
|
1903
2360
|
if (!node) return false;
|
|
1904
|
-
if (node.type ===
|
|
2361
|
+
if (node.type === AST_NODE_TYPES29.ConditionalExpression) {
|
|
1905
2362
|
return true;
|
|
1906
2363
|
}
|
|
1907
|
-
if (node.type ===
|
|
2364
|
+
if (node.type === AST_NODE_TYPES29.LogicalExpression) {
|
|
1908
2365
|
return true;
|
|
1909
2366
|
}
|
|
1910
|
-
if (node.type ===
|
|
2367
|
+
if (node.type === AST_NODE_TYPES29.NewExpression) {
|
|
1911
2368
|
return true;
|
|
1912
2369
|
}
|
|
1913
2370
|
return false;
|
|
@@ -1927,11 +2384,11 @@ var noComplexInlineReturn = createRule24({
|
|
|
1927
2384
|
var no_complex_inline_return_default = noComplexInlineReturn;
|
|
1928
2385
|
|
|
1929
2386
|
// src/rules/no-direct-date.ts
|
|
1930
|
-
import { AST_NODE_TYPES as
|
|
1931
|
-
var
|
|
2387
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES30, ESLintUtils as ESLintUtils29 } from "@typescript-eslint/utils";
|
|
2388
|
+
var createRule29 = ESLintUtils29.RuleCreator(
|
|
1932
2389
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1933
2390
|
);
|
|
1934
|
-
var noDirectDate =
|
|
2391
|
+
var noDirectDate = createRule29({
|
|
1935
2392
|
name: "no-direct-date",
|
|
1936
2393
|
meta: {
|
|
1937
2394
|
type: "problem",
|
|
@@ -1949,7 +2406,7 @@ var noDirectDate = createRule25({
|
|
|
1949
2406
|
create(context) {
|
|
1950
2407
|
return {
|
|
1951
2408
|
NewExpression(node) {
|
|
1952
|
-
if (node.callee.type ===
|
|
2409
|
+
if (node.callee.type === AST_NODE_TYPES30.Identifier && node.callee.name === "Date") {
|
|
1953
2410
|
context.report({
|
|
1954
2411
|
node,
|
|
1955
2412
|
messageId: "noNewDate"
|
|
@@ -1957,7 +2414,7 @@ var noDirectDate = createRule25({
|
|
|
1957
2414
|
}
|
|
1958
2415
|
},
|
|
1959
2416
|
CallExpression(node) {
|
|
1960
|
-
if (node.callee.type ===
|
|
2417
|
+
if (node.callee.type === AST_NODE_TYPES30.MemberExpression && node.callee.object.type === AST_NODE_TYPES30.Identifier && node.callee.object.name === "Date" && node.callee.property.type === AST_NODE_TYPES30.Identifier) {
|
|
1961
2418
|
const methodName = node.callee.property.name;
|
|
1962
2419
|
if (methodName === "now") {
|
|
1963
2420
|
context.report({
|
|
@@ -1980,11 +2437,11 @@ var no_direct_date_default = noDirectDate;
|
|
|
1980
2437
|
|
|
1981
2438
|
// src/rules/no-emoji.ts
|
|
1982
2439
|
import emojiRegex from "emoji-regex";
|
|
1983
|
-
import { ESLintUtils as
|
|
1984
|
-
var
|
|
2440
|
+
import { ESLintUtils as ESLintUtils30 } from "@typescript-eslint/utils";
|
|
2441
|
+
var createRule30 = ESLintUtils30.RuleCreator(
|
|
1985
2442
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1986
2443
|
);
|
|
1987
|
-
var noEmoji =
|
|
2444
|
+
var noEmoji = createRule30({
|
|
1988
2445
|
name: "no-emoji",
|
|
1989
2446
|
meta: {
|
|
1990
2447
|
type: "problem",
|
|
@@ -2018,11 +2475,11 @@ var noEmoji = createRule26({
|
|
|
2018
2475
|
var no_emoji_default = noEmoji;
|
|
2019
2476
|
|
|
2020
2477
|
// src/rules/no-env-fallback.ts
|
|
2021
|
-
import { AST_NODE_TYPES as
|
|
2022
|
-
var
|
|
2478
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES31, ESLintUtils as ESLintUtils31 } from "@typescript-eslint/utils";
|
|
2479
|
+
var createRule31 = ESLintUtils31.RuleCreator(
|
|
2023
2480
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2024
2481
|
);
|
|
2025
|
-
var noEnvFallback =
|
|
2482
|
+
var noEnvFallback = createRule31({
|
|
2026
2483
|
name: "no-env-fallback",
|
|
2027
2484
|
meta: {
|
|
2028
2485
|
type: "problem",
|
|
@@ -2037,16 +2494,16 @@ var noEnvFallback = createRule27({
|
|
|
2037
2494
|
defaultOptions: [],
|
|
2038
2495
|
create(context) {
|
|
2039
2496
|
const isProcessEnvAccess = (node) => {
|
|
2040
|
-
if (node.type !==
|
|
2497
|
+
if (node.type !== AST_NODE_TYPES31.MemberExpression) {
|
|
2041
2498
|
return false;
|
|
2042
2499
|
}
|
|
2043
2500
|
const { object } = node;
|
|
2044
|
-
if (object.type !==
|
|
2501
|
+
if (object.type !== AST_NODE_TYPES31.MemberExpression) {
|
|
2045
2502
|
return false;
|
|
2046
2503
|
}
|
|
2047
2504
|
const processNode = object.object;
|
|
2048
2505
|
const envNode = object.property;
|
|
2049
|
-
return processNode.type ===
|
|
2506
|
+
return processNode.type === AST_NODE_TYPES31.Identifier && processNode.name === "process" && envNode.type === AST_NODE_TYPES31.Identifier && envNode.name === "env";
|
|
2050
2507
|
};
|
|
2051
2508
|
return {
|
|
2052
2509
|
LogicalExpression(node) {
|
|
@@ -2070,12 +2527,58 @@ var noEnvFallback = createRule27({
|
|
|
2070
2527
|
});
|
|
2071
2528
|
var no_env_fallback_default = noEnvFallback;
|
|
2072
2529
|
|
|
2530
|
+
// src/rules/no-ghost-wrapper.ts
|
|
2531
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES32, ESLintUtils as ESLintUtils32 } from "@typescript-eslint/utils";
|
|
2532
|
+
var createRule32 = ESLintUtils32.RuleCreator(
|
|
2533
|
+
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2534
|
+
);
|
|
2535
|
+
var GHOST_TAGS = /* @__PURE__ */ new Set(["div", "span"]);
|
|
2536
|
+
function isKeyAttribute(attribute) {
|
|
2537
|
+
return attribute.type === AST_NODE_TYPES32.JSXAttribute && attribute.name.type === AST_NODE_TYPES32.JSXIdentifier && attribute.name.name === "key";
|
|
2538
|
+
}
|
|
2539
|
+
var noGhostWrapper = createRule32({
|
|
2540
|
+
name: "no-ghost-wrapper",
|
|
2541
|
+
meta: {
|
|
2542
|
+
type: "problem",
|
|
2543
|
+
docs: {
|
|
2544
|
+
description: "Disallow bare <div> and <span> elements that have no meaningful attributes (Divitis / ghost wrappers)"
|
|
2545
|
+
},
|
|
2546
|
+
schema: [],
|
|
2547
|
+
messages: {
|
|
2548
|
+
noGhostWrapper: "Ghost <{{ tag }}> has no meaningful attributes. Use a Fragment (<>...</>), a semantic element (section, article, header, etc.), or add a meaningful attribute (className, role, data-*, ref, etc.). Note: 'key' alone does not count as meaningful."
|
|
2549
|
+
}
|
|
2550
|
+
},
|
|
2551
|
+
defaultOptions: [],
|
|
2552
|
+
create(context) {
|
|
2553
|
+
return {
|
|
2554
|
+
JSXOpeningElement(node) {
|
|
2555
|
+
if (node.name.type !== AST_NODE_TYPES32.JSXIdentifier) {
|
|
2556
|
+
return;
|
|
2557
|
+
}
|
|
2558
|
+
const tagName = node.name.name;
|
|
2559
|
+
if (!GHOST_TAGS.has(tagName)) {
|
|
2560
|
+
return;
|
|
2561
|
+
}
|
|
2562
|
+
const meaningfulAttributes = node.attributes.filter((attribute) => !isKeyAttribute(attribute));
|
|
2563
|
+
if (meaningfulAttributes.length === 0) {
|
|
2564
|
+
context.report({
|
|
2565
|
+
node,
|
|
2566
|
+
messageId: "noGhostWrapper",
|
|
2567
|
+
data: { tag: tagName }
|
|
2568
|
+
});
|
|
2569
|
+
}
|
|
2570
|
+
}
|
|
2571
|
+
};
|
|
2572
|
+
}
|
|
2573
|
+
});
|
|
2574
|
+
var no_ghost_wrapper_default = noGhostWrapper;
|
|
2575
|
+
|
|
2073
2576
|
// src/rules/no-inline-default-export.ts
|
|
2074
|
-
import { AST_NODE_TYPES as
|
|
2075
|
-
var
|
|
2577
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES33, ESLintUtils as ESLintUtils33 } from "@typescript-eslint/utils";
|
|
2578
|
+
var createRule33 = ESLintUtils33.RuleCreator(
|
|
2076
2579
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2077
2580
|
);
|
|
2078
|
-
var noInlineDefaultExport =
|
|
2581
|
+
var noInlineDefaultExport = createRule33({
|
|
2079
2582
|
name: "no-inline-default-export",
|
|
2080
2583
|
meta: {
|
|
2081
2584
|
type: "suggestion",
|
|
@@ -2094,7 +2597,7 @@ var noInlineDefaultExport = createRule28({
|
|
|
2094
2597
|
return {
|
|
2095
2598
|
ExportDefaultDeclaration(node) {
|
|
2096
2599
|
const { declaration } = node;
|
|
2097
|
-
if (declaration.type ===
|
|
2600
|
+
if (declaration.type === AST_NODE_TYPES33.FunctionDeclaration) {
|
|
2098
2601
|
if (declaration.id) {
|
|
2099
2602
|
context.report({
|
|
2100
2603
|
node,
|
|
@@ -2109,7 +2612,7 @@ var noInlineDefaultExport = createRule28({
|
|
|
2109
2612
|
});
|
|
2110
2613
|
}
|
|
2111
2614
|
}
|
|
2112
|
-
if (declaration.type ===
|
|
2615
|
+
if (declaration.type === AST_NODE_TYPES33.ClassDeclaration) {
|
|
2113
2616
|
if (declaration.id) {
|
|
2114
2617
|
context.report({
|
|
2115
2618
|
node,
|
|
@@ -2124,7 +2627,7 @@ var noInlineDefaultExport = createRule28({
|
|
|
2124
2627
|
});
|
|
2125
2628
|
}
|
|
2126
2629
|
}
|
|
2127
|
-
if (declaration.type ===
|
|
2630
|
+
if (declaration.type === AST_NODE_TYPES33.ArrowFunctionExpression || declaration.type === AST_NODE_TYPES33.FunctionExpression) {
|
|
2128
2631
|
context.report({
|
|
2129
2632
|
node,
|
|
2130
2633
|
messageId: "noAnonymousDefaultExport",
|
|
@@ -2137,14 +2640,14 @@ var noInlineDefaultExport = createRule28({
|
|
|
2137
2640
|
if (!declaration) {
|
|
2138
2641
|
return;
|
|
2139
2642
|
}
|
|
2140
|
-
if (declaration.type ===
|
|
2643
|
+
if (declaration.type === AST_NODE_TYPES33.FunctionDeclaration && declaration.id) {
|
|
2141
2644
|
context.report({
|
|
2142
2645
|
node,
|
|
2143
2646
|
messageId: "noInlineNamedExport",
|
|
2144
2647
|
data: { type: "function", name: declaration.id.name }
|
|
2145
2648
|
});
|
|
2146
2649
|
}
|
|
2147
|
-
if (declaration.type ===
|
|
2650
|
+
if (declaration.type === AST_NODE_TYPES33.ClassDeclaration && declaration.id) {
|
|
2148
2651
|
context.report({
|
|
2149
2652
|
node,
|
|
2150
2653
|
messageId: "noInlineNamedExport",
|
|
@@ -2158,27 +2661,27 @@ var noInlineDefaultExport = createRule28({
|
|
|
2158
2661
|
var no_inline_default_export_default = noInlineDefaultExport;
|
|
2159
2662
|
|
|
2160
2663
|
// src/rules/no-inline-nested-object.ts
|
|
2161
|
-
import { AST_NODE_TYPES as
|
|
2162
|
-
var
|
|
2664
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES34, ESLintUtils as ESLintUtils34 } from "@typescript-eslint/utils";
|
|
2665
|
+
var createRule34 = ESLintUtils34.RuleCreator(
|
|
2163
2666
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2164
2667
|
);
|
|
2165
2668
|
function isObjectOrArray(node) {
|
|
2166
|
-
return node.type ===
|
|
2669
|
+
return node.type === AST_NODE_TYPES34.ObjectExpression || node.type === AST_NODE_TYPES34.ArrayExpression || node.type === AST_NODE_TYPES34.TSAsExpression;
|
|
2167
2670
|
}
|
|
2168
2671
|
function getInnerExpression(node) {
|
|
2169
|
-
if (node.type ===
|
|
2672
|
+
if (node.type === AST_NODE_TYPES34.TSAsExpression) {
|
|
2170
2673
|
return getInnerExpression(node.expression);
|
|
2171
2674
|
}
|
|
2172
2675
|
return node;
|
|
2173
2676
|
}
|
|
2174
2677
|
function isNestedStructure(node) {
|
|
2175
2678
|
const inner = getInnerExpression(node);
|
|
2176
|
-
return inner.type ===
|
|
2679
|
+
return inner.type === AST_NODE_TYPES34.ObjectExpression || inner.type === AST_NODE_TYPES34.ArrayExpression;
|
|
2177
2680
|
}
|
|
2178
2681
|
function containsNestedStructure(node) {
|
|
2179
|
-
if (node.type ===
|
|
2682
|
+
if (node.type === AST_NODE_TYPES34.ObjectExpression) {
|
|
2180
2683
|
return node.properties.some((prop) => {
|
|
2181
|
-
if (prop.type !==
|
|
2684
|
+
if (prop.type !== AST_NODE_TYPES34.Property) return false;
|
|
2182
2685
|
return isNestedStructure(prop.value);
|
|
2183
2686
|
});
|
|
2184
2687
|
}
|
|
@@ -2187,7 +2690,7 @@ function containsNestedStructure(node) {
|
|
|
2187
2690
|
return isNestedStructure(el);
|
|
2188
2691
|
});
|
|
2189
2692
|
}
|
|
2190
|
-
var noInlineNestedObject =
|
|
2693
|
+
var noInlineNestedObject = createRule34({
|
|
2191
2694
|
name: "no-inline-nested-object",
|
|
2192
2695
|
meta: {
|
|
2193
2696
|
type: "layout",
|
|
@@ -2209,7 +2712,7 @@ var noInlineNestedObject = createRule29({
|
|
|
2209
2712
|
return;
|
|
2210
2713
|
}
|
|
2211
2714
|
const valueNode = getInnerExpression(node.value);
|
|
2212
|
-
if (valueNode.type !==
|
|
2715
|
+
if (valueNode.type !== AST_NODE_TYPES34.ObjectExpression && valueNode.type !== AST_NODE_TYPES34.ArrayExpression) {
|
|
2213
2716
|
return;
|
|
2214
2717
|
}
|
|
2215
2718
|
if (!valueNode.loc) {
|
|
@@ -2222,7 +2725,7 @@ var noInlineNestedObject = createRule29({
|
|
|
2222
2725
|
if (!containsNestedStructure(valueNode)) {
|
|
2223
2726
|
return;
|
|
2224
2727
|
}
|
|
2225
|
-
const elements = valueNode.type ===
|
|
2728
|
+
const elements = valueNode.type === AST_NODE_TYPES34.ObjectExpression ? valueNode.properties : valueNode.elements;
|
|
2226
2729
|
context.report({
|
|
2227
2730
|
node: valueNode,
|
|
2228
2731
|
messageId: "requireMultiline",
|
|
@@ -2235,7 +2738,7 @@ var noInlineNestedObject = createRule29({
|
|
|
2235
2738
|
const indent = " ".repeat(node.loc?.start.column ?? 0);
|
|
2236
2739
|
const innerIndent = `${indent} `;
|
|
2237
2740
|
const elementTexts = elements.filter((el) => el !== null).map((el) => sourceCode.getText(el));
|
|
2238
|
-
const isObject = valueNode.type ===
|
|
2741
|
+
const isObject = valueNode.type === AST_NODE_TYPES34.ObjectExpression;
|
|
2239
2742
|
const openChar = isObject ? "{" : "[";
|
|
2240
2743
|
const closeChar = isObject ? "}" : "]";
|
|
2241
2744
|
const formattedElements = elementTexts.map((text) => `${innerIndent}${text},`).join("\n");
|
|
@@ -2252,20 +2755,20 @@ ${indent}${closeChar}`;
|
|
|
2252
2755
|
var no_inline_nested_object_default = noInlineNestedObject;
|
|
2253
2756
|
|
|
2254
2757
|
// src/rules/no-inline-return-properties.ts
|
|
2255
|
-
import { AST_NODE_TYPES as
|
|
2256
|
-
var
|
|
2758
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES35, ESLintUtils as ESLintUtils35 } from "@typescript-eslint/utils";
|
|
2759
|
+
var createRule35 = ESLintUtils35.RuleCreator(
|
|
2257
2760
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2258
2761
|
);
|
|
2259
2762
|
var isShorthandProperty = (property) => {
|
|
2260
|
-
if (property.type ===
|
|
2763
|
+
if (property.type === AST_NODE_TYPES35.SpreadElement) {
|
|
2261
2764
|
return true;
|
|
2262
2765
|
}
|
|
2263
|
-
if (property.type !==
|
|
2766
|
+
if (property.type !== AST_NODE_TYPES35.Property) {
|
|
2264
2767
|
return false;
|
|
2265
2768
|
}
|
|
2266
2769
|
return property.shorthand;
|
|
2267
2770
|
};
|
|
2268
|
-
var noInlineReturnProperties =
|
|
2771
|
+
var noInlineReturnProperties = createRule35({
|
|
2269
2772
|
name: "no-inline-return-properties",
|
|
2270
2773
|
meta: {
|
|
2271
2774
|
type: "suggestion",
|
|
@@ -2281,20 +2784,20 @@ var noInlineReturnProperties = createRule30({
|
|
|
2281
2784
|
create(context) {
|
|
2282
2785
|
return {
|
|
2283
2786
|
ReturnStatement(node) {
|
|
2284
|
-
if (!node.argument || node.argument.type !==
|
|
2787
|
+
if (!node.argument || node.argument.type !== AST_NODE_TYPES35.ObjectExpression) {
|
|
2285
2788
|
return;
|
|
2286
2789
|
}
|
|
2287
2790
|
node.argument.properties.forEach((property) => {
|
|
2288
2791
|
if (isShorthandProperty(property)) {
|
|
2289
2792
|
return;
|
|
2290
2793
|
}
|
|
2291
|
-
if (property.type !==
|
|
2794
|
+
if (property.type !== AST_NODE_TYPES35.Property) {
|
|
2292
2795
|
return;
|
|
2293
2796
|
}
|
|
2294
2797
|
let keyName = null;
|
|
2295
|
-
if (property.key.type ===
|
|
2798
|
+
if (property.key.type === AST_NODE_TYPES35.Identifier) {
|
|
2296
2799
|
keyName = property.key.name;
|
|
2297
|
-
} else if (property.key.type ===
|
|
2800
|
+
} else if (property.key.type === AST_NODE_TYPES35.Literal) {
|
|
2298
2801
|
keyName = String(property.key.value);
|
|
2299
2802
|
}
|
|
2300
2803
|
context.report({
|
|
@@ -2310,12 +2813,12 @@ var noInlineReturnProperties = createRule30({
|
|
|
2310
2813
|
var no_inline_return_properties_default = noInlineReturnProperties;
|
|
2311
2814
|
|
|
2312
2815
|
// src/rules/no-inline-type-import.ts
|
|
2313
|
-
import { AST_NODE_TYPES as
|
|
2314
|
-
var
|
|
2816
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES36, ESLintUtils as ESLintUtils36 } from "@typescript-eslint/utils";
|
|
2817
|
+
var createRule36 = ESLintUtils36.RuleCreator(
|
|
2315
2818
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2316
2819
|
);
|
|
2317
|
-
var isInlineTypeSpecifier = (specifier) => specifier.type ===
|
|
2318
|
-
var noInlineTypeImport =
|
|
2820
|
+
var isInlineTypeSpecifier = (specifier) => specifier.type === AST_NODE_TYPES36.ImportSpecifier && specifier.importKind === "type";
|
|
2821
|
+
var noInlineTypeImport = createRule36({
|
|
2319
2822
|
name: "no-inline-type-import",
|
|
2320
2823
|
meta: {
|
|
2321
2824
|
type: "suggestion",
|
|
@@ -2352,7 +2855,7 @@ var noInlineTypeImport = createRule31({
|
|
|
2352
2855
|
);
|
|
2353
2856
|
const typeImport = `import type { ${typeSpecifierTexts.join(", ")} } from ${sourceText};`;
|
|
2354
2857
|
const valueSpecifiers = node.specifiers.filter(
|
|
2355
|
-
(specifier) => !(specifier.type ===
|
|
2858
|
+
(specifier) => !(specifier.type === AST_NODE_TYPES36.ImportSpecifier && specifier.importKind === "type")
|
|
2356
2859
|
);
|
|
2357
2860
|
if (valueSpecifiers.length === 0) {
|
|
2358
2861
|
return fixer.replaceText(node, typeImport);
|
|
@@ -2360,11 +2863,11 @@ var noInlineTypeImport = createRule31({
|
|
|
2360
2863
|
const parts = [];
|
|
2361
2864
|
const namedValueSpecifiers = [];
|
|
2362
2865
|
for (const specifier of valueSpecifiers) {
|
|
2363
|
-
if (specifier.type ===
|
|
2866
|
+
if (specifier.type === AST_NODE_TYPES36.ImportDefaultSpecifier) {
|
|
2364
2867
|
parts.push(specifier.local.name);
|
|
2365
|
-
} else if (specifier.type ===
|
|
2868
|
+
} else if (specifier.type === AST_NODE_TYPES36.ImportNamespaceSpecifier) {
|
|
2366
2869
|
parts.push(`* as ${specifier.local.name}`);
|
|
2367
|
-
} else if (specifier.type ===
|
|
2870
|
+
} else if (specifier.type === AST_NODE_TYPES36.ImportSpecifier) {
|
|
2368
2871
|
namedValueSpecifiers.push(specifier);
|
|
2369
2872
|
}
|
|
2370
2873
|
}
|
|
@@ -2384,8 +2887,8 @@ ${typeImport}`);
|
|
|
2384
2887
|
var no_inline_type_import_default = noInlineTypeImport;
|
|
2385
2888
|
|
|
2386
2889
|
// src/rules/no-lazy-identifiers.ts
|
|
2387
|
-
import { AST_NODE_TYPES as
|
|
2388
|
-
var
|
|
2890
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES37, ESLintUtils as ESLintUtils37 } from "@typescript-eslint/utils";
|
|
2891
|
+
var createRule37 = ESLintUtils37.RuleCreator(
|
|
2389
2892
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2390
2893
|
);
|
|
2391
2894
|
var KEYBOARD_ROWS = ["qwertyuiop", "asdfghjkl", "zxcvbnm", "1234567890"];
|
|
@@ -2426,7 +2929,7 @@ var isLazyIdentifier = (name) => {
|
|
|
2426
2929
|
}
|
|
2427
2930
|
return false;
|
|
2428
2931
|
};
|
|
2429
|
-
var noLazyIdentifiers =
|
|
2932
|
+
var noLazyIdentifiers = createRule37({
|
|
2430
2933
|
name: "no-lazy-identifiers",
|
|
2431
2934
|
meta: {
|
|
2432
2935
|
type: "problem",
|
|
@@ -2452,27 +2955,27 @@ var noLazyIdentifiers = createRule32({
|
|
|
2452
2955
|
});
|
|
2453
2956
|
};
|
|
2454
2957
|
const checkPattern = (pattern) => {
|
|
2455
|
-
if (pattern.type ===
|
|
2958
|
+
if (pattern.type === AST_NODE_TYPES37.Identifier) {
|
|
2456
2959
|
checkIdentifier(pattern);
|
|
2457
|
-
} else if (pattern.type ===
|
|
2960
|
+
} else if (pattern.type === AST_NODE_TYPES37.ObjectPattern) {
|
|
2458
2961
|
pattern.properties.forEach((prop) => {
|
|
2459
|
-
if (prop.type ===
|
|
2962
|
+
if (prop.type === AST_NODE_TYPES37.Property && prop.value.type === AST_NODE_TYPES37.Identifier) {
|
|
2460
2963
|
checkIdentifier(prop.value);
|
|
2461
|
-
} else if (prop.type ===
|
|
2964
|
+
} else if (prop.type === AST_NODE_TYPES37.RestElement && prop.argument.type === AST_NODE_TYPES37.Identifier) {
|
|
2462
2965
|
checkIdentifier(prop.argument);
|
|
2463
2966
|
}
|
|
2464
2967
|
});
|
|
2465
|
-
} else if (pattern.type ===
|
|
2968
|
+
} else if (pattern.type === AST_NODE_TYPES37.ArrayPattern) {
|
|
2466
2969
|
pattern.elements.forEach((element) => {
|
|
2467
|
-
if (element?.type ===
|
|
2970
|
+
if (element?.type === AST_NODE_TYPES37.Identifier) {
|
|
2468
2971
|
checkIdentifier(element);
|
|
2469
|
-
} else if (element?.type ===
|
|
2972
|
+
} else if (element?.type === AST_NODE_TYPES37.RestElement && element.argument.type === AST_NODE_TYPES37.Identifier) {
|
|
2470
2973
|
checkIdentifier(element.argument);
|
|
2471
2974
|
}
|
|
2472
2975
|
});
|
|
2473
|
-
} else if (pattern.type ===
|
|
2976
|
+
} else if (pattern.type === AST_NODE_TYPES37.AssignmentPattern && pattern.left.type === AST_NODE_TYPES37.Identifier) {
|
|
2474
2977
|
checkIdentifier(pattern.left);
|
|
2475
|
-
} else if (pattern.type ===
|
|
2978
|
+
} else if (pattern.type === AST_NODE_TYPES37.RestElement && pattern.argument.type === AST_NODE_TYPES37.Identifier) {
|
|
2476
2979
|
checkIdentifier(pattern.argument);
|
|
2477
2980
|
}
|
|
2478
2981
|
};
|
|
@@ -2517,11 +3020,11 @@ var noLazyIdentifiers = createRule32({
|
|
|
2517
3020
|
var no_lazy_identifiers_default = noLazyIdentifiers;
|
|
2518
3021
|
|
|
2519
3022
|
// src/rules/no-logic-in-params.ts
|
|
2520
|
-
import { AST_NODE_TYPES as
|
|
2521
|
-
var
|
|
3023
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES38, ESLintUtils as ESLintUtils38 } from "@typescript-eslint/utils";
|
|
3024
|
+
var createRule38 = ESLintUtils38.RuleCreator(
|
|
2522
3025
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2523
3026
|
);
|
|
2524
|
-
var noLogicInParams =
|
|
3027
|
+
var noLogicInParams = createRule38({
|
|
2525
3028
|
name: "no-logic-in-params",
|
|
2526
3029
|
meta: {
|
|
2527
3030
|
type: "suggestion",
|
|
@@ -2536,20 +3039,20 @@ var noLogicInParams = createRule33({
|
|
|
2536
3039
|
defaultOptions: [],
|
|
2537
3040
|
create(context) {
|
|
2538
3041
|
const isComplexExpression = (node) => {
|
|
2539
|
-
if (node.type ===
|
|
3042
|
+
if (node.type === AST_NODE_TYPES38.SpreadElement) {
|
|
2540
3043
|
return false;
|
|
2541
3044
|
}
|
|
2542
|
-
if (node.type ===
|
|
3045
|
+
if (node.type === AST_NODE_TYPES38.ConditionalExpression) {
|
|
2543
3046
|
return true;
|
|
2544
3047
|
}
|
|
2545
|
-
if (node.type ===
|
|
3048
|
+
if (node.type === AST_NODE_TYPES38.LogicalExpression) {
|
|
2546
3049
|
return true;
|
|
2547
3050
|
}
|
|
2548
|
-
if (node.type ===
|
|
3051
|
+
if (node.type === AST_NODE_TYPES38.BinaryExpression) {
|
|
2549
3052
|
const logicalOperators = ["==", "===", "!=", "!==", "<", ">", "<=", ">=", "in", "instanceof"];
|
|
2550
3053
|
return logicalOperators.includes(node.operator);
|
|
2551
3054
|
}
|
|
2552
|
-
if (node.type ===
|
|
3055
|
+
if (node.type === AST_NODE_TYPES38.UnaryExpression) {
|
|
2553
3056
|
return node.operator === "!";
|
|
2554
3057
|
}
|
|
2555
3058
|
return false;
|
|
@@ -2562,7 +3065,7 @@ var noLogicInParams = createRule33({
|
|
|
2562
3065
|
messageId: "noLogicInParams"
|
|
2563
3066
|
});
|
|
2564
3067
|
}
|
|
2565
|
-
if (arg.type ===
|
|
3068
|
+
if (arg.type === AST_NODE_TYPES38.ArrayExpression) {
|
|
2566
3069
|
arg.elements.forEach((element) => {
|
|
2567
3070
|
if (element && isComplexExpression(element)) {
|
|
2568
3071
|
context.report({
|
|
@@ -2587,46 +3090,46 @@ var noLogicInParams = createRule33({
|
|
|
2587
3090
|
var no_logic_in_params_default = noLogicInParams;
|
|
2588
3091
|
|
|
2589
3092
|
// src/rules/no-misleading-constant-case.ts
|
|
2590
|
-
import { AST_NODE_TYPES as
|
|
2591
|
-
var
|
|
3093
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES39, ESLintUtils as ESLintUtils39 } from "@typescript-eslint/utils";
|
|
3094
|
+
var createRule39 = ESLintUtils39.RuleCreator(
|
|
2592
3095
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2593
3096
|
);
|
|
2594
3097
|
var SCREAMING_SNAKE_CASE_REGEX3 = /^[A-Z][A-Z0-9]*(?:_[A-Z0-9]+)*$/;
|
|
2595
|
-
var isAsConstAssertion = (node) => node.type ===
|
|
3098
|
+
var isAsConstAssertion = (node) => node.type === AST_NODE_TYPES39.TSAsExpression && node.typeAnnotation.type === AST_NODE_TYPES39.TSTypeReference && node.typeAnnotation.typeName.type === AST_NODE_TYPES39.Identifier && node.typeAnnotation.typeName.name === "const";
|
|
2596
3099
|
var isStaticValue2 = (init) => {
|
|
2597
3100
|
if (isAsConstAssertion(init)) {
|
|
2598
3101
|
return true;
|
|
2599
3102
|
}
|
|
2600
|
-
if (init.type ===
|
|
3103
|
+
if (init.type === AST_NODE_TYPES39.Literal) {
|
|
2601
3104
|
return true;
|
|
2602
3105
|
}
|
|
2603
|
-
if (init.type ===
|
|
3106
|
+
if (init.type === AST_NODE_TYPES39.UnaryExpression && init.argument.type === AST_NODE_TYPES39.Literal) {
|
|
2604
3107
|
return true;
|
|
2605
3108
|
}
|
|
2606
|
-
if (init.type ===
|
|
3109
|
+
if (init.type === AST_NODE_TYPES39.TemplateLiteral && init.expressions.length === 0) {
|
|
2607
3110
|
return true;
|
|
2608
3111
|
}
|
|
2609
|
-
if (init.type ===
|
|
2610
|
-
return init.elements.every((el) => el !== null && el.type !==
|
|
3112
|
+
if (init.type === AST_NODE_TYPES39.ArrayExpression) {
|
|
3113
|
+
return init.elements.every((el) => el !== null && el.type !== AST_NODE_TYPES39.SpreadElement && isStaticValue2(el));
|
|
2611
3114
|
}
|
|
2612
|
-
if (init.type ===
|
|
3115
|
+
if (init.type === AST_NODE_TYPES39.ObjectExpression) {
|
|
2613
3116
|
return init.properties.every(
|
|
2614
|
-
(prop) => prop.type ===
|
|
3117
|
+
(prop) => prop.type === AST_NODE_TYPES39.Property && isStaticValue2(prop.value)
|
|
2615
3118
|
);
|
|
2616
3119
|
}
|
|
2617
3120
|
return false;
|
|
2618
3121
|
};
|
|
2619
3122
|
var isGlobalScope3 = (node) => {
|
|
2620
3123
|
const { parent } = node;
|
|
2621
|
-
if (parent.type ===
|
|
3124
|
+
if (parent.type === AST_NODE_TYPES39.Program) {
|
|
2622
3125
|
return true;
|
|
2623
3126
|
}
|
|
2624
|
-
if (parent.type ===
|
|
3127
|
+
if (parent.type === AST_NODE_TYPES39.ExportNamedDeclaration && parent.parent?.type === AST_NODE_TYPES39.Program) {
|
|
2625
3128
|
return true;
|
|
2626
3129
|
}
|
|
2627
3130
|
return false;
|
|
2628
3131
|
};
|
|
2629
|
-
var noMisleadingConstantCase =
|
|
3132
|
+
var noMisleadingConstantCase = createRule39({
|
|
2630
3133
|
name: "no-misleading-constant-case",
|
|
2631
3134
|
meta: {
|
|
2632
3135
|
type: "suggestion",
|
|
@@ -2645,7 +3148,7 @@ var noMisleadingConstantCase = createRule34({
|
|
|
2645
3148
|
return {
|
|
2646
3149
|
VariableDeclaration(node) {
|
|
2647
3150
|
node.declarations.forEach((declarator) => {
|
|
2648
|
-
if (declarator.id.type !==
|
|
3151
|
+
if (declarator.id.type !== AST_NODE_TYPES39.Identifier) {
|
|
2649
3152
|
return;
|
|
2650
3153
|
}
|
|
2651
3154
|
const { name } = declarator.id;
|
|
@@ -2686,11 +3189,11 @@ var noMisleadingConstantCase = createRule34({
|
|
|
2686
3189
|
var no_misleading_constant_case_default = noMisleadingConstantCase;
|
|
2687
3190
|
|
|
2688
3191
|
// src/rules/no-nested-interface-declaration.ts
|
|
2689
|
-
import { AST_NODE_TYPES as
|
|
2690
|
-
var
|
|
3192
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES40, ESLintUtils as ESLintUtils40 } from "@typescript-eslint/utils";
|
|
3193
|
+
var createRule40 = ESLintUtils40.RuleCreator(
|
|
2691
3194
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2692
3195
|
);
|
|
2693
|
-
var noNestedInterfaceDeclaration =
|
|
3196
|
+
var noNestedInterfaceDeclaration = createRule40({
|
|
2694
3197
|
name: "no-nested-interface-declaration",
|
|
2695
3198
|
meta: {
|
|
2696
3199
|
type: "suggestion",
|
|
@@ -2711,15 +3214,15 @@ var noNestedInterfaceDeclaration = createRule35({
|
|
|
2711
3214
|
return;
|
|
2712
3215
|
}
|
|
2713
3216
|
const { typeAnnotation } = node.typeAnnotation;
|
|
2714
|
-
if (typeAnnotation.type ===
|
|
3217
|
+
if (typeAnnotation.type === AST_NODE_TYPES40.TSTypeLiteral) {
|
|
2715
3218
|
context.report({
|
|
2716
3219
|
node: typeAnnotation,
|
|
2717
3220
|
messageId: "noNestedInterface"
|
|
2718
3221
|
});
|
|
2719
3222
|
return;
|
|
2720
3223
|
}
|
|
2721
|
-
if (typeAnnotation.type ===
|
|
2722
|
-
if (typeAnnotation.elementType.type ===
|
|
3224
|
+
if (typeAnnotation.type === AST_NODE_TYPES40.TSArrayType) {
|
|
3225
|
+
if (typeAnnotation.elementType.type === AST_NODE_TYPES40.TSTypeLiteral) {
|
|
2723
3226
|
context.report({
|
|
2724
3227
|
node: typeAnnotation.elementType,
|
|
2725
3228
|
messageId: "noNestedInterface"
|
|
@@ -2727,9 +3230,9 @@ var noNestedInterfaceDeclaration = createRule35({
|
|
|
2727
3230
|
}
|
|
2728
3231
|
return;
|
|
2729
3232
|
}
|
|
2730
|
-
if (typeAnnotation.type ===
|
|
3233
|
+
if (typeAnnotation.type === AST_NODE_TYPES40.TSTypeReference && typeAnnotation.typeArguments) {
|
|
2731
3234
|
typeAnnotation.typeArguments.params.forEach((param) => {
|
|
2732
|
-
if (param.type ===
|
|
3235
|
+
if (param.type === AST_NODE_TYPES40.TSTypeLiteral) {
|
|
2733
3236
|
context.report({
|
|
2734
3237
|
node: param,
|
|
2735
3238
|
messageId: "noNestedInterface"
|
|
@@ -2744,11 +3247,11 @@ var noNestedInterfaceDeclaration = createRule35({
|
|
|
2744
3247
|
var no_nested_interface_declaration_default = noNestedInterfaceDeclaration;
|
|
2745
3248
|
|
|
2746
3249
|
// src/rules/no-nested-ternary.ts
|
|
2747
|
-
import { AST_NODE_TYPES as
|
|
2748
|
-
var
|
|
3250
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES41, ESLintUtils as ESLintUtils41 } from "@typescript-eslint/utils";
|
|
3251
|
+
var createRule41 = ESLintUtils41.RuleCreator(
|
|
2749
3252
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2750
3253
|
);
|
|
2751
|
-
var noNestedTernary =
|
|
3254
|
+
var noNestedTernary = createRule41({
|
|
2752
3255
|
name: "no-nested-ternary",
|
|
2753
3256
|
meta: {
|
|
2754
3257
|
type: "suggestion",
|
|
@@ -2765,13 +3268,13 @@ var noNestedTernary = createRule36({
|
|
|
2765
3268
|
return {
|
|
2766
3269
|
ConditionalExpression(node) {
|
|
2767
3270
|
const { consequent, alternate } = node;
|
|
2768
|
-
if (consequent.type ===
|
|
3271
|
+
if (consequent.type === AST_NODE_TYPES41.ConditionalExpression) {
|
|
2769
3272
|
context.report({
|
|
2770
3273
|
node: consequent,
|
|
2771
3274
|
messageId: "noNestedTernary"
|
|
2772
3275
|
});
|
|
2773
3276
|
}
|
|
2774
|
-
if (alternate.type ===
|
|
3277
|
+
if (alternate.type === AST_NODE_TYPES41.ConditionalExpression) {
|
|
2775
3278
|
context.report({
|
|
2776
3279
|
node: alternate,
|
|
2777
3280
|
messageId: "noNestedTernary"
|
|
@@ -2783,12 +3286,86 @@ var noNestedTernary = createRule36({
|
|
|
2783
3286
|
});
|
|
2784
3287
|
var no_nested_ternary_default = noNestedTernary;
|
|
2785
3288
|
|
|
3289
|
+
// src/rules/no-redundant-fragment.ts
|
|
3290
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES42, ESLintUtils as ESLintUtils42 } from "@typescript-eslint/utils";
|
|
3291
|
+
var createRule42 = ESLintUtils42.RuleCreator(
|
|
3292
|
+
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3293
|
+
);
|
|
3294
|
+
function isFragmentName(name) {
|
|
3295
|
+
if (name.type === AST_NODE_TYPES42.JSXIdentifier && name.name === "Fragment") {
|
|
3296
|
+
return true;
|
|
3297
|
+
}
|
|
3298
|
+
if (name.type === AST_NODE_TYPES42.JSXMemberExpression && name.object.type === AST_NODE_TYPES42.JSXIdentifier && name.object.name === "React" && name.property.type === AST_NODE_TYPES42.JSXIdentifier && name.property.name === "Fragment") {
|
|
3299
|
+
return true;
|
|
3300
|
+
}
|
|
3301
|
+
return false;
|
|
3302
|
+
}
|
|
3303
|
+
function hasKeyAttribute(attributes) {
|
|
3304
|
+
return attributes.some(
|
|
3305
|
+
(attribute) => attribute.type === AST_NODE_TYPES42.JSXAttribute && attribute.name.type === AST_NODE_TYPES42.JSXIdentifier && attribute.name.name === "key"
|
|
3306
|
+
);
|
|
3307
|
+
}
|
|
3308
|
+
function countMeaningfulChildren(children) {
|
|
3309
|
+
return children.filter((child) => {
|
|
3310
|
+
if (child.type === AST_NODE_TYPES42.JSXText) {
|
|
3311
|
+
return child.value.trim() !== "";
|
|
3312
|
+
}
|
|
3313
|
+
return true;
|
|
3314
|
+
}).length;
|
|
3315
|
+
}
|
|
3316
|
+
var noRedundantFragment = createRule42({
|
|
3317
|
+
name: "no-redundant-fragment",
|
|
3318
|
+
meta: {
|
|
3319
|
+
type: "problem",
|
|
3320
|
+
docs: {
|
|
3321
|
+
description: "Disallow Fragments that wrap zero or one child (unless a key prop is needed)"
|
|
3322
|
+
},
|
|
3323
|
+
schema: [],
|
|
3324
|
+
messages: {
|
|
3325
|
+
redundantFragment: "Fragment is redundant when wrapping {{ count }} child. Remove the Fragment or replace it with the child directly."
|
|
3326
|
+
}
|
|
3327
|
+
},
|
|
3328
|
+
defaultOptions: [],
|
|
3329
|
+
create(context) {
|
|
3330
|
+
return {
|
|
3331
|
+
JSXFragment(node) {
|
|
3332
|
+
const count = countMeaningfulChildren(node.children);
|
|
3333
|
+
if (count <= 1) {
|
|
3334
|
+
context.report({
|
|
3335
|
+
node,
|
|
3336
|
+
messageId: "redundantFragment",
|
|
3337
|
+
data: { count: String(count) }
|
|
3338
|
+
});
|
|
3339
|
+
}
|
|
3340
|
+
},
|
|
3341
|
+
JSXElement(node) {
|
|
3342
|
+
const opening = node.openingElement;
|
|
3343
|
+
if (!isFragmentName(opening.name)) {
|
|
3344
|
+
return;
|
|
3345
|
+
}
|
|
3346
|
+
if (hasKeyAttribute(opening.attributes)) {
|
|
3347
|
+
return;
|
|
3348
|
+
}
|
|
3349
|
+
const count = countMeaningfulChildren(node.children);
|
|
3350
|
+
if (count <= 1) {
|
|
3351
|
+
context.report({
|
|
3352
|
+
node,
|
|
3353
|
+
messageId: "redundantFragment",
|
|
3354
|
+
data: { count: String(count) }
|
|
3355
|
+
});
|
|
3356
|
+
}
|
|
3357
|
+
}
|
|
3358
|
+
};
|
|
3359
|
+
}
|
|
3360
|
+
});
|
|
3361
|
+
var no_redundant_fragment_default = noRedundantFragment;
|
|
3362
|
+
|
|
2786
3363
|
// src/rules/no-relative-imports.ts
|
|
2787
|
-
import { AST_NODE_TYPES as
|
|
2788
|
-
var
|
|
3364
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES43, ESLintUtils as ESLintUtils43 } from "@typescript-eslint/utils";
|
|
3365
|
+
var createRule43 = ESLintUtils43.RuleCreator(
|
|
2789
3366
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2790
3367
|
);
|
|
2791
|
-
var noRelativeImports =
|
|
3368
|
+
var noRelativeImports = createRule43({
|
|
2792
3369
|
name: "no-relative-imports",
|
|
2793
3370
|
meta: {
|
|
2794
3371
|
type: "suggestion",
|
|
@@ -2812,22 +3389,22 @@ var noRelativeImports = createRule37({
|
|
|
2812
3389
|
};
|
|
2813
3390
|
return {
|
|
2814
3391
|
ImportDeclaration(node) {
|
|
2815
|
-
if (node.source.type ===
|
|
3392
|
+
if (node.source.type === AST_NODE_TYPES43.Literal && typeof node.source.value === "string") {
|
|
2816
3393
|
checkImportPath(node.source.value, node);
|
|
2817
3394
|
}
|
|
2818
3395
|
},
|
|
2819
3396
|
ImportExpression(node) {
|
|
2820
|
-
if (node.source.type ===
|
|
3397
|
+
if (node.source.type === AST_NODE_TYPES43.Literal && typeof node.source.value === "string") {
|
|
2821
3398
|
checkImportPath(node.source.value, node);
|
|
2822
3399
|
}
|
|
2823
3400
|
},
|
|
2824
3401
|
ExportNamedDeclaration(node) {
|
|
2825
|
-
if (node.source?.type ===
|
|
3402
|
+
if (node.source?.type === AST_NODE_TYPES43.Literal && typeof node.source.value === "string") {
|
|
2826
3403
|
checkImportPath(node.source.value, node);
|
|
2827
3404
|
}
|
|
2828
3405
|
},
|
|
2829
3406
|
ExportAllDeclaration(node) {
|
|
2830
|
-
if (node.source.type ===
|
|
3407
|
+
if (node.source.type === AST_NODE_TYPES43.Literal && typeof node.source.value === "string") {
|
|
2831
3408
|
checkImportPath(node.source.value, node);
|
|
2832
3409
|
}
|
|
2833
3410
|
}
|
|
@@ -2837,8 +3414,8 @@ var noRelativeImports = createRule37({
|
|
|
2837
3414
|
var no_relative_imports_default = noRelativeImports;
|
|
2838
3415
|
|
|
2839
3416
|
// src/rules/no-single-char-variables.ts
|
|
2840
|
-
import { AST_NODE_TYPES as
|
|
2841
|
-
var
|
|
3417
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES44, ESLintUtils as ESLintUtils44 } from "@typescript-eslint/utils";
|
|
3418
|
+
var createRule44 = ESLintUtils44.RuleCreator(
|
|
2842
3419
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2843
3420
|
);
|
|
2844
3421
|
var ALLOWED_IN_FOR_LOOPS = /* @__PURE__ */ new Set(["i", "j", "k", "n"]);
|
|
@@ -2850,7 +3427,7 @@ var isForLoopInit = (node) => {
|
|
|
2850
3427
|
if (!parentNode) {
|
|
2851
3428
|
return false;
|
|
2852
3429
|
}
|
|
2853
|
-
if (parentNode.type ===
|
|
3430
|
+
if (parentNode.type === AST_NODE_TYPES44.ForStatement) {
|
|
2854
3431
|
const { init } = parentNode;
|
|
2855
3432
|
if (init && init === current) {
|
|
2856
3433
|
return true;
|
|
@@ -2869,7 +3446,7 @@ var isAllowedInContext = (name, node) => {
|
|
|
2869
3446
|
}
|
|
2870
3447
|
return false;
|
|
2871
3448
|
};
|
|
2872
|
-
var noSingleCharVariables =
|
|
3449
|
+
var noSingleCharVariables = createRule44({
|
|
2873
3450
|
name: "no-single-char-variables",
|
|
2874
3451
|
meta: {
|
|
2875
3452
|
type: "suggestion",
|
|
@@ -2898,27 +3475,27 @@ var noSingleCharVariables = createRule38({
|
|
|
2898
3475
|
});
|
|
2899
3476
|
};
|
|
2900
3477
|
const checkPattern = (pattern, declarationNode) => {
|
|
2901
|
-
if (pattern.type ===
|
|
3478
|
+
if (pattern.type === AST_NODE_TYPES44.Identifier) {
|
|
2902
3479
|
checkIdentifier(pattern, declarationNode);
|
|
2903
|
-
} else if (pattern.type ===
|
|
3480
|
+
} else if (pattern.type === AST_NODE_TYPES44.ObjectPattern) {
|
|
2904
3481
|
pattern.properties.forEach((prop) => {
|
|
2905
|
-
if (prop.type ===
|
|
3482
|
+
if (prop.type === AST_NODE_TYPES44.Property && prop.value.type === AST_NODE_TYPES44.Identifier) {
|
|
2906
3483
|
checkIdentifier(prop.value, declarationNode);
|
|
2907
|
-
} else if (prop.type ===
|
|
3484
|
+
} else if (prop.type === AST_NODE_TYPES44.RestElement && prop.argument.type === AST_NODE_TYPES44.Identifier) {
|
|
2908
3485
|
checkIdentifier(prop.argument, declarationNode);
|
|
2909
3486
|
}
|
|
2910
3487
|
});
|
|
2911
|
-
} else if (pattern.type ===
|
|
3488
|
+
} else if (pattern.type === AST_NODE_TYPES44.ArrayPattern) {
|
|
2912
3489
|
pattern.elements.forEach((element) => {
|
|
2913
|
-
if (element?.type ===
|
|
3490
|
+
if (element?.type === AST_NODE_TYPES44.Identifier) {
|
|
2914
3491
|
checkIdentifier(element, declarationNode);
|
|
2915
|
-
} else if (element?.type ===
|
|
3492
|
+
} else if (element?.type === AST_NODE_TYPES44.RestElement && element.argument.type === AST_NODE_TYPES44.Identifier) {
|
|
2916
3493
|
checkIdentifier(element.argument, declarationNode);
|
|
2917
3494
|
}
|
|
2918
3495
|
});
|
|
2919
|
-
} else if (pattern.type ===
|
|
3496
|
+
} else if (pattern.type === AST_NODE_TYPES44.AssignmentPattern && pattern.left.type === AST_NODE_TYPES44.Identifier) {
|
|
2920
3497
|
checkIdentifier(pattern.left, declarationNode);
|
|
2921
|
-
} else if (pattern.type ===
|
|
3498
|
+
} else if (pattern.type === AST_NODE_TYPES44.RestElement && pattern.argument.type === AST_NODE_TYPES44.Identifier) {
|
|
2922
3499
|
checkIdentifier(pattern.argument, declarationNode);
|
|
2923
3500
|
}
|
|
2924
3501
|
};
|
|
@@ -2952,11 +3529,11 @@ var noSingleCharVariables = createRule38({
|
|
|
2952
3529
|
var no_single_char_variables_default = noSingleCharVariables;
|
|
2953
3530
|
|
|
2954
3531
|
// src/rules/prefer-async-await.ts
|
|
2955
|
-
import { AST_NODE_TYPES as
|
|
2956
|
-
var
|
|
3532
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES45, ESLintUtils as ESLintUtils45 } from "@typescript-eslint/utils";
|
|
3533
|
+
var createRule45 = ESLintUtils45.RuleCreator(
|
|
2957
3534
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2958
3535
|
);
|
|
2959
|
-
var preferAsyncAwait =
|
|
3536
|
+
var preferAsyncAwait = createRule45({
|
|
2960
3537
|
name: "prefer-async-await",
|
|
2961
3538
|
meta: {
|
|
2962
3539
|
type: "suggestion",
|
|
@@ -2972,7 +3549,7 @@ var preferAsyncAwait = createRule39({
|
|
|
2972
3549
|
create(context) {
|
|
2973
3550
|
return {
|
|
2974
3551
|
CallExpression(node) {
|
|
2975
|
-
if (node.callee.type ===
|
|
3552
|
+
if (node.callee.type === AST_NODE_TYPES45.MemberExpression && node.callee.property.type === AST_NODE_TYPES45.Identifier && node.callee.property.name === "then") {
|
|
2976
3553
|
context.report({
|
|
2977
3554
|
node: node.callee.property,
|
|
2978
3555
|
messageId: "preferAsyncAwait"
|
|
@@ -2985,11 +3562,11 @@ var preferAsyncAwait = createRule39({
|
|
|
2985
3562
|
var prefer_async_await_default = preferAsyncAwait;
|
|
2986
3563
|
|
|
2987
3564
|
// src/rules/prefer-destructuring-params.ts
|
|
2988
|
-
import { AST_NODE_TYPES as
|
|
2989
|
-
var
|
|
3565
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES46, ESLintUtils as ESLintUtils46 } from "@typescript-eslint/utils";
|
|
3566
|
+
var createRule46 = ESLintUtils46.RuleCreator(
|
|
2990
3567
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2991
3568
|
);
|
|
2992
|
-
var preferDestructuringParams =
|
|
3569
|
+
var preferDestructuringParams = createRule46({
|
|
2993
3570
|
name: "prefer-destructuring-params",
|
|
2994
3571
|
meta: {
|
|
2995
3572
|
type: "suggestion",
|
|
@@ -3005,18 +3582,18 @@ var preferDestructuringParams = createRule40({
|
|
|
3005
3582
|
create(context) {
|
|
3006
3583
|
const isCallbackFunction2 = (node) => {
|
|
3007
3584
|
const { parent } = node;
|
|
3008
|
-
return parent?.type ===
|
|
3585
|
+
return parent?.type === AST_NODE_TYPES46.CallExpression;
|
|
3009
3586
|
};
|
|
3010
3587
|
const isDeveloperFunction = (node) => {
|
|
3011
|
-
if (node.type ===
|
|
3588
|
+
if (node.type === AST_NODE_TYPES46.FunctionDeclaration) {
|
|
3012
3589
|
return true;
|
|
3013
3590
|
}
|
|
3014
|
-
if (node.type ===
|
|
3591
|
+
if (node.type === AST_NODE_TYPES46.FunctionExpression || node.type === AST_NODE_TYPES46.ArrowFunctionExpression) {
|
|
3015
3592
|
if (isCallbackFunction2(node)) {
|
|
3016
3593
|
return false;
|
|
3017
3594
|
}
|
|
3018
3595
|
const { parent } = node;
|
|
3019
|
-
return parent?.type ===
|
|
3596
|
+
return parent?.type === AST_NODE_TYPES46.VariableDeclarator || parent?.type === AST_NODE_TYPES46.AssignmentExpression || parent?.type === AST_NODE_TYPES46.Property || parent?.type === AST_NODE_TYPES46.MethodDefinition;
|
|
3020
3597
|
}
|
|
3021
3598
|
return false;
|
|
3022
3599
|
};
|
|
@@ -3028,7 +3605,7 @@ var preferDestructuringParams = createRule40({
|
|
|
3028
3605
|
if (!isDeveloperFunction(node)) {
|
|
3029
3606
|
return;
|
|
3030
3607
|
}
|
|
3031
|
-
if (node.type ===
|
|
3608
|
+
if (node.type === AST_NODE_TYPES46.FunctionDeclaration && node.id) {
|
|
3032
3609
|
const functionName = node.id.name;
|
|
3033
3610
|
if (functionName.startsWith("_") || functionName.includes("$") || /^[A-Z][a-zA-Z]*$/.test(functionName)) {
|
|
3034
3611
|
return;
|
|
@@ -3038,7 +3615,7 @@ var preferDestructuringParams = createRule40({
|
|
|
3038
3615
|
return;
|
|
3039
3616
|
}
|
|
3040
3617
|
const hasNonDestructuredParams = node.params.some(
|
|
3041
|
-
(param) => param.type !==
|
|
3618
|
+
(param) => param.type !== AST_NODE_TYPES46.ObjectPattern && param.type !== AST_NODE_TYPES46.RestElement
|
|
3042
3619
|
);
|
|
3043
3620
|
if (hasNonDestructuredParams) {
|
|
3044
3621
|
context.report({
|
|
@@ -3057,8 +3634,8 @@ var preferDestructuringParams = createRule40({
|
|
|
3057
3634
|
var prefer_destructuring_params_default = preferDestructuringParams;
|
|
3058
3635
|
|
|
3059
3636
|
// src/rules/prefer-function-declaration.ts
|
|
3060
|
-
import { AST_NODE_TYPES as
|
|
3061
|
-
var
|
|
3637
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES47, ESLintUtils as ESLintUtils47 } from "@typescript-eslint/utils";
|
|
3638
|
+
var createRule47 = ESLintUtils47.RuleCreator(
|
|
3062
3639
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3063
3640
|
);
|
|
3064
3641
|
var isTsFile = (filename) => filename.endsWith(".ts") && !filename.endsWith(".d.ts");
|
|
@@ -3067,33 +3644,33 @@ var isCallbackContext = (node) => {
|
|
|
3067
3644
|
if (!parent) {
|
|
3068
3645
|
return false;
|
|
3069
3646
|
}
|
|
3070
|
-
if (parent.type ===
|
|
3647
|
+
if (parent.type === AST_NODE_TYPES47.CallExpression && parent.arguments.includes(node)) {
|
|
3071
3648
|
return true;
|
|
3072
3649
|
}
|
|
3073
|
-
if (parent.type ===
|
|
3650
|
+
if (parent.type === AST_NODE_TYPES47.NewExpression && parent.arguments.includes(node)) {
|
|
3074
3651
|
return true;
|
|
3075
3652
|
}
|
|
3076
|
-
if (parent.type ===
|
|
3653
|
+
if (parent.type === AST_NODE_TYPES47.ReturnStatement) {
|
|
3077
3654
|
return true;
|
|
3078
3655
|
}
|
|
3079
|
-
if (parent.type ===
|
|
3656
|
+
if (parent.type === AST_NODE_TYPES47.Property) {
|
|
3080
3657
|
return true;
|
|
3081
3658
|
}
|
|
3082
|
-
if (parent.type ===
|
|
3659
|
+
if (parent.type === AST_NODE_TYPES47.ArrayExpression) {
|
|
3083
3660
|
return true;
|
|
3084
3661
|
}
|
|
3085
|
-
if (parent.type ===
|
|
3662
|
+
if (parent.type === AST_NODE_TYPES47.ConditionalExpression) {
|
|
3086
3663
|
return true;
|
|
3087
3664
|
}
|
|
3088
|
-
if (parent.type ===
|
|
3665
|
+
if (parent.type === AST_NODE_TYPES47.LogicalExpression) {
|
|
3089
3666
|
return true;
|
|
3090
3667
|
}
|
|
3091
|
-
if (parent.type ===
|
|
3668
|
+
if (parent.type === AST_NODE_TYPES47.AssignmentExpression && parent.left !== node) {
|
|
3092
3669
|
return true;
|
|
3093
3670
|
}
|
|
3094
3671
|
return false;
|
|
3095
3672
|
};
|
|
3096
|
-
var preferFunctionDeclaration =
|
|
3673
|
+
var preferFunctionDeclaration = createRule47({
|
|
3097
3674
|
name: "prefer-function-declaration",
|
|
3098
3675
|
meta: {
|
|
3099
3676
|
type: "suggestion",
|
|
@@ -3114,14 +3691,14 @@ var preferFunctionDeclaration = createRule41({
|
|
|
3114
3691
|
}
|
|
3115
3692
|
return {
|
|
3116
3693
|
VariableDeclarator(node) {
|
|
3117
|
-
if (node.id.type !==
|
|
3694
|
+
if (node.id.type !== AST_NODE_TYPES47.Identifier) {
|
|
3118
3695
|
return;
|
|
3119
3696
|
}
|
|
3120
3697
|
const { init } = node;
|
|
3121
3698
|
if (!init) {
|
|
3122
3699
|
return;
|
|
3123
3700
|
}
|
|
3124
|
-
if (init.type ===
|
|
3701
|
+
if (init.type === AST_NODE_TYPES47.ArrowFunctionExpression) {
|
|
3125
3702
|
if (isCallbackContext(init)) {
|
|
3126
3703
|
return;
|
|
3127
3704
|
}
|
|
@@ -3131,7 +3708,7 @@ var preferFunctionDeclaration = createRule41({
|
|
|
3131
3708
|
data: { name: node.id.name }
|
|
3132
3709
|
});
|
|
3133
3710
|
}
|
|
3134
|
-
if (init.type ===
|
|
3711
|
+
if (init.type === AST_NODE_TYPES47.FunctionExpression) {
|
|
3135
3712
|
if (isCallbackContext(init)) {
|
|
3136
3713
|
return;
|
|
3137
3714
|
}
|
|
@@ -3148,11 +3725,11 @@ var preferFunctionDeclaration = createRule41({
|
|
|
3148
3725
|
var prefer_function_declaration_default = preferFunctionDeclaration;
|
|
3149
3726
|
|
|
3150
3727
|
// src/rules/prefer-guard-clause.ts
|
|
3151
|
-
import { AST_NODE_TYPES as
|
|
3152
|
-
var
|
|
3728
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES48, ESLintUtils as ESLintUtils48 } from "@typescript-eslint/utils";
|
|
3729
|
+
var createRule48 = ESLintUtils48.RuleCreator(
|
|
3153
3730
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3154
3731
|
);
|
|
3155
|
-
var preferGuardClause =
|
|
3732
|
+
var preferGuardClause = createRule48({
|
|
3156
3733
|
name: "prefer-guard-clause",
|
|
3157
3734
|
meta: {
|
|
3158
3735
|
type: "suggestion",
|
|
@@ -3169,8 +3746,8 @@ var preferGuardClause = createRule42({
|
|
|
3169
3746
|
return {
|
|
3170
3747
|
IfStatement(node) {
|
|
3171
3748
|
const { consequent } = node;
|
|
3172
|
-
if (consequent.type ===
|
|
3173
|
-
const hasNestedIf = consequent.body.some((statement) => statement.type ===
|
|
3749
|
+
if (consequent.type === AST_NODE_TYPES48.BlockStatement) {
|
|
3750
|
+
const hasNestedIf = consequent.body.some((statement) => statement.type === AST_NODE_TYPES48.IfStatement);
|
|
3174
3751
|
if (hasNestedIf && consequent.body.length === 1) {
|
|
3175
3752
|
context.report({
|
|
3176
3753
|
node,
|
|
@@ -3178,7 +3755,7 @@ var preferGuardClause = createRule42({
|
|
|
3178
3755
|
});
|
|
3179
3756
|
}
|
|
3180
3757
|
}
|
|
3181
|
-
if (consequent.type ===
|
|
3758
|
+
if (consequent.type === AST_NODE_TYPES48.IfStatement) {
|
|
3182
3759
|
context.report({
|
|
3183
3760
|
node,
|
|
3184
3761
|
messageId: "preferGuardClause"
|
|
@@ -3191,11 +3768,11 @@ var preferGuardClause = createRule42({
|
|
|
3191
3768
|
var prefer_guard_clause_default = preferGuardClause;
|
|
3192
3769
|
|
|
3193
3770
|
// src/rules/prefer-import-type.ts
|
|
3194
|
-
import { AST_NODE_TYPES as
|
|
3195
|
-
var
|
|
3771
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES49, ESLintUtils as ESLintUtils49 } from "@typescript-eslint/utils";
|
|
3772
|
+
var createRule49 = ESLintUtils49.RuleCreator(
|
|
3196
3773
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3197
3774
|
);
|
|
3198
|
-
var preferImportType =
|
|
3775
|
+
var preferImportType = createRule49({
|
|
3199
3776
|
name: "prefer-import-type",
|
|
3200
3777
|
meta: {
|
|
3201
3778
|
type: "suggestion",
|
|
@@ -3214,22 +3791,22 @@ var preferImportType = createRule43({
|
|
|
3214
3791
|
let current = node;
|
|
3215
3792
|
while (current) {
|
|
3216
3793
|
switch (current.type) {
|
|
3217
|
-
case
|
|
3218
|
-
case
|
|
3219
|
-
case
|
|
3220
|
-
case
|
|
3221
|
-
case
|
|
3222
|
-
case
|
|
3223
|
-
case
|
|
3224
|
-
case
|
|
3225
|
-
case
|
|
3226
|
-
case
|
|
3227
|
-
case
|
|
3228
|
-
case
|
|
3229
|
-
case
|
|
3794
|
+
case AST_NODE_TYPES49.TSTypeReference:
|
|
3795
|
+
case AST_NODE_TYPES49.TSTypeAnnotation:
|
|
3796
|
+
case AST_NODE_TYPES49.TSTypeParameterInstantiation:
|
|
3797
|
+
case AST_NODE_TYPES49.TSInterfaceHeritage:
|
|
3798
|
+
case AST_NODE_TYPES49.TSClassImplements:
|
|
3799
|
+
case AST_NODE_TYPES49.TSTypeQuery:
|
|
3800
|
+
case AST_NODE_TYPES49.TSTypeAssertion:
|
|
3801
|
+
case AST_NODE_TYPES49.TSAsExpression:
|
|
3802
|
+
case AST_NODE_TYPES49.TSSatisfiesExpression:
|
|
3803
|
+
case AST_NODE_TYPES49.TSTypeAliasDeclaration:
|
|
3804
|
+
case AST_NODE_TYPES49.TSInterfaceDeclaration:
|
|
3805
|
+
case AST_NODE_TYPES49.TSTypeParameter:
|
|
3806
|
+
case AST_NODE_TYPES49.TSQualifiedName:
|
|
3230
3807
|
return true;
|
|
3231
|
-
case
|
|
3232
|
-
case
|
|
3808
|
+
case AST_NODE_TYPES49.MemberExpression:
|
|
3809
|
+
case AST_NODE_TYPES49.Identifier:
|
|
3233
3810
|
current = current.parent;
|
|
3234
3811
|
break;
|
|
3235
3812
|
default:
|
|
@@ -3259,27 +3836,27 @@ var preferImportType = createRule43({
|
|
|
3259
3836
|
return false;
|
|
3260
3837
|
}
|
|
3261
3838
|
switch (parent.type) {
|
|
3262
|
-
case
|
|
3263
|
-
case
|
|
3264
|
-
case
|
|
3265
|
-
case
|
|
3266
|
-
case
|
|
3267
|
-
case
|
|
3268
|
-
case
|
|
3269
|
-
case
|
|
3270
|
-
case
|
|
3271
|
-
case
|
|
3272
|
-
case
|
|
3273
|
-
case
|
|
3274
|
-
case
|
|
3275
|
-
case
|
|
3276
|
-
case
|
|
3277
|
-
case
|
|
3278
|
-
case
|
|
3279
|
-
case
|
|
3280
|
-
case
|
|
3281
|
-
case
|
|
3282
|
-
case
|
|
3839
|
+
case AST_NODE_TYPES49.CallExpression:
|
|
3840
|
+
case AST_NODE_TYPES49.NewExpression:
|
|
3841
|
+
case AST_NODE_TYPES49.JSXOpeningElement:
|
|
3842
|
+
case AST_NODE_TYPES49.JSXClosingElement:
|
|
3843
|
+
case AST_NODE_TYPES49.MemberExpression:
|
|
3844
|
+
case AST_NODE_TYPES49.VariableDeclarator:
|
|
3845
|
+
case AST_NODE_TYPES49.TaggedTemplateExpression:
|
|
3846
|
+
case AST_NODE_TYPES49.SpreadElement:
|
|
3847
|
+
case AST_NODE_TYPES49.ExportSpecifier:
|
|
3848
|
+
case AST_NODE_TYPES49.ArrayExpression:
|
|
3849
|
+
case AST_NODE_TYPES49.ObjectExpression:
|
|
3850
|
+
case AST_NODE_TYPES49.BinaryExpression:
|
|
3851
|
+
case AST_NODE_TYPES49.LogicalExpression:
|
|
3852
|
+
case AST_NODE_TYPES49.UnaryExpression:
|
|
3853
|
+
case AST_NODE_TYPES49.ReturnStatement:
|
|
3854
|
+
case AST_NODE_TYPES49.ArrowFunctionExpression:
|
|
3855
|
+
case AST_NODE_TYPES49.ConditionalExpression:
|
|
3856
|
+
case AST_NODE_TYPES49.AwaitExpression:
|
|
3857
|
+
case AST_NODE_TYPES49.YieldExpression:
|
|
3858
|
+
case AST_NODE_TYPES49.Property:
|
|
3859
|
+
case AST_NODE_TYPES49.JSXExpressionContainer:
|
|
3283
3860
|
return true;
|
|
3284
3861
|
default:
|
|
3285
3862
|
return false;
|
|
@@ -3291,7 +3868,7 @@ var preferImportType = createRule43({
|
|
|
3291
3868
|
return;
|
|
3292
3869
|
}
|
|
3293
3870
|
const hasInlineTypeSpecifier = node.specifiers.some(
|
|
3294
|
-
(specifier) => specifier.type ===
|
|
3871
|
+
(specifier) => specifier.type === AST_NODE_TYPES49.ImportSpecifier && specifier.importKind === "type"
|
|
3295
3872
|
);
|
|
3296
3873
|
if (hasInlineTypeSpecifier) {
|
|
3297
3874
|
return;
|
|
@@ -3309,13 +3886,13 @@ var preferImportType = createRule43({
|
|
|
3309
3886
|
}
|
|
3310
3887
|
const scope = context.sourceCode.getScope(node);
|
|
3311
3888
|
const isTypeOnlyImport2 = node.specifiers.every((specifier) => {
|
|
3312
|
-
if (specifier.type ===
|
|
3889
|
+
if (specifier.type === AST_NODE_TYPES49.ImportDefaultSpecifier) {
|
|
3313
3890
|
return false;
|
|
3314
3891
|
}
|
|
3315
|
-
if (specifier.type ===
|
|
3892
|
+
if (specifier.type === AST_NODE_TYPES49.ImportNamespaceSpecifier) {
|
|
3316
3893
|
return false;
|
|
3317
3894
|
}
|
|
3318
|
-
if (specifier.type ===
|
|
3895
|
+
if (specifier.type === AST_NODE_TYPES49.ImportSpecifier) {
|
|
3319
3896
|
const localName = specifier.local.name;
|
|
3320
3897
|
return !isUsedAsValue(localName, scope);
|
|
3321
3898
|
}
|
|
@@ -3341,19 +3918,19 @@ var preferImportType = createRule43({
|
|
|
3341
3918
|
var prefer_import_type_default = preferImportType;
|
|
3342
3919
|
|
|
3343
3920
|
// src/rules/prefer-inline-literal-union.ts
|
|
3344
|
-
import { AST_NODE_TYPES as
|
|
3345
|
-
var
|
|
3921
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES50, ESLintUtils as ESLintUtils50 } from "@typescript-eslint/utils";
|
|
3922
|
+
var createRule50 = ESLintUtils50.RuleCreator(
|
|
3346
3923
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3347
3924
|
);
|
|
3348
3925
|
function isLiteralUnionType(node) {
|
|
3349
|
-
if (node.type !==
|
|
3926
|
+
if (node.type !== AST_NODE_TYPES50.TSUnionType) {
|
|
3350
3927
|
return false;
|
|
3351
3928
|
}
|
|
3352
3929
|
return node.types.every(
|
|
3353
|
-
(member) => member.type ===
|
|
3930
|
+
(member) => member.type === AST_NODE_TYPES50.TSLiteralType || member.type === AST_NODE_TYPES50.TSNullKeyword || member.type === AST_NODE_TYPES50.TSUndefinedKeyword
|
|
3354
3931
|
);
|
|
3355
3932
|
}
|
|
3356
|
-
var preferInlineLiteralUnion =
|
|
3933
|
+
var preferInlineLiteralUnion = createRule50({
|
|
3357
3934
|
name: "prefer-inline-literal-union",
|
|
3358
3935
|
meta: {
|
|
3359
3936
|
type: "suggestion",
|
|
@@ -3380,10 +3957,10 @@ var preferInlineLiteralUnion = createRule44({
|
|
|
3380
3957
|
return;
|
|
3381
3958
|
}
|
|
3382
3959
|
const { typeAnnotation } = node.typeAnnotation;
|
|
3383
|
-
if (typeAnnotation.type !==
|
|
3960
|
+
if (typeAnnotation.type !== AST_NODE_TYPES50.TSTypeReference) {
|
|
3384
3961
|
return;
|
|
3385
3962
|
}
|
|
3386
|
-
if (typeAnnotation.typeName.type !==
|
|
3963
|
+
if (typeAnnotation.typeName.type !== AST_NODE_TYPES50.Identifier) {
|
|
3387
3964
|
return;
|
|
3388
3965
|
}
|
|
3389
3966
|
const aliasName = typeAnnotation.typeName.name;
|
|
@@ -3407,12 +3984,12 @@ var preferInlineLiteralUnion = createRule44({
|
|
|
3407
3984
|
var prefer_inline_literal_union_default = preferInlineLiteralUnion;
|
|
3408
3985
|
|
|
3409
3986
|
// src/rules/prefer-inline-type-export.ts
|
|
3410
|
-
import { AST_NODE_TYPES as
|
|
3411
|
-
var
|
|
3987
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES51, ESLintUtils as ESLintUtils51 } from "@typescript-eslint/utils";
|
|
3988
|
+
var createRule51 = ESLintUtils51.RuleCreator(
|
|
3412
3989
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3413
3990
|
);
|
|
3414
|
-
var isTypeDeclaration = (node) => node.type ===
|
|
3415
|
-
var preferInlineTypeExport =
|
|
3991
|
+
var isTypeDeclaration = (node) => node.type === AST_NODE_TYPES51.TSInterfaceDeclaration || node.type === AST_NODE_TYPES51.TSTypeAliasDeclaration;
|
|
3992
|
+
var preferInlineTypeExport = createRule51({
|
|
3416
3993
|
name: "prefer-inline-type-export",
|
|
3417
3994
|
meta: {
|
|
3418
3995
|
type: "suggestion",
|
|
@@ -3429,12 +4006,12 @@ var preferInlineTypeExport = createRule45({
|
|
|
3429
4006
|
create(context) {
|
|
3430
4007
|
const typeDeclarations = /* @__PURE__ */ new Map();
|
|
3431
4008
|
function collectDeclaration(node) {
|
|
3432
|
-
if (node.parent.type !==
|
|
4009
|
+
if (node.parent.type !== AST_NODE_TYPES51.ExportNamedDeclaration) {
|
|
3433
4010
|
typeDeclarations.set(node.id.name, node);
|
|
3434
4011
|
}
|
|
3435
4012
|
}
|
|
3436
4013
|
function reportSpecifier(specifier, statement, declarationNode) {
|
|
3437
|
-
if (specifier.local.type !==
|
|
4014
|
+
if (specifier.local.type !== AST_NODE_TYPES51.Identifier) {
|
|
3438
4015
|
return;
|
|
3439
4016
|
}
|
|
3440
4017
|
const { name } = specifier.local;
|
|
@@ -3467,16 +4044,16 @@ var preferInlineTypeExport = createRule45({
|
|
|
3467
4044
|
return {
|
|
3468
4045
|
Program(node) {
|
|
3469
4046
|
node.body.forEach((statement) => {
|
|
3470
|
-
if (statement.type ===
|
|
4047
|
+
if (statement.type === AST_NODE_TYPES51.TSInterfaceDeclaration || statement.type === AST_NODE_TYPES51.TSTypeAliasDeclaration) {
|
|
3471
4048
|
collectDeclaration(statement);
|
|
3472
4049
|
}
|
|
3473
4050
|
});
|
|
3474
4051
|
node.body.forEach((statement) => {
|
|
3475
|
-
if (statement.type !==
|
|
4052
|
+
if (statement.type !== AST_NODE_TYPES51.ExportNamedDeclaration || statement.declaration !== null) {
|
|
3476
4053
|
return;
|
|
3477
4054
|
}
|
|
3478
4055
|
statement.specifiers.forEach((specifier) => {
|
|
3479
|
-
if (specifier.local.type !==
|
|
4056
|
+
if (specifier.local.type !== AST_NODE_TYPES51.Identifier) {
|
|
3480
4057
|
return;
|
|
3481
4058
|
}
|
|
3482
4059
|
const declarationNode = typeDeclarations.get(specifier.local.name);
|
|
@@ -3493,11 +4070,11 @@ var preferInlineTypeExport = createRule45({
|
|
|
3493
4070
|
var prefer_inline_type_export_default = preferInlineTypeExport;
|
|
3494
4071
|
|
|
3495
4072
|
// src/rules/prefer-interface-for-component-props.ts
|
|
3496
|
-
import { AST_NODE_TYPES as
|
|
3497
|
-
var
|
|
4073
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES52, ESLintUtils as ESLintUtils52 } from "@typescript-eslint/utils";
|
|
4074
|
+
var createRule52 = ESLintUtils52.RuleCreator(
|
|
3498
4075
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3499
4076
|
);
|
|
3500
|
-
var preferInterfaceForComponentProps =
|
|
4077
|
+
var preferInterfaceForComponentProps = createRule52({
|
|
3501
4078
|
name: "prefer-interface-for-component-props",
|
|
3502
4079
|
meta: {
|
|
3503
4080
|
type: "suggestion",
|
|
@@ -3517,13 +4094,13 @@ var preferInterfaceForComponentProps = createRule46({
|
|
|
3517
4094
|
}
|
|
3518
4095
|
return {
|
|
3519
4096
|
TSTypeAliasDeclaration(node) {
|
|
3520
|
-
if (node.id.type !==
|
|
4097
|
+
if (node.id.type !== AST_NODE_TYPES52.Identifier) {
|
|
3521
4098
|
return;
|
|
3522
4099
|
}
|
|
3523
4100
|
if (!node.id.name.endsWith("Props")) {
|
|
3524
4101
|
return;
|
|
3525
4102
|
}
|
|
3526
|
-
if (node.typeAnnotation.type !==
|
|
4103
|
+
if (node.typeAnnotation.type !== AST_NODE_TYPES52.TSTypeLiteral) {
|
|
3527
4104
|
return;
|
|
3528
4105
|
}
|
|
3529
4106
|
const { name } = node.id;
|
|
@@ -3550,11 +4127,11 @@ var preferInterfaceForComponentProps = createRule46({
|
|
|
3550
4127
|
var prefer_interface_for_component_props_default = preferInterfaceForComponentProps;
|
|
3551
4128
|
|
|
3552
4129
|
// src/rules/prefer-interface-over-inline-types.ts
|
|
3553
|
-
import { AST_NODE_TYPES as
|
|
3554
|
-
var
|
|
4130
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES53, ESLintUtils as ESLintUtils53 } from "@typescript-eslint/utils";
|
|
4131
|
+
var createRule53 = ESLintUtils53.RuleCreator(
|
|
3555
4132
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3556
4133
|
);
|
|
3557
|
-
var preferInterfaceOverInlineTypes =
|
|
4134
|
+
var preferInterfaceOverInlineTypes = createRule53({
|
|
3558
4135
|
name: "prefer-interface-over-inline-types",
|
|
3559
4136
|
meta: {
|
|
3560
4137
|
type: "suggestion",
|
|
@@ -3570,54 +4147,54 @@ var preferInterfaceOverInlineTypes = createRule47({
|
|
|
3570
4147
|
defaultOptions: [],
|
|
3571
4148
|
create(context) {
|
|
3572
4149
|
function hasJSXInConditional(node) {
|
|
3573
|
-
return node.consequent.type ===
|
|
4150
|
+
return node.consequent.type === AST_NODE_TYPES53.JSXElement || node.consequent.type === AST_NODE_TYPES53.JSXFragment || node.alternate.type === AST_NODE_TYPES53.JSXElement || node.alternate.type === AST_NODE_TYPES53.JSXFragment;
|
|
3574
4151
|
}
|
|
3575
4152
|
function hasJSXInLogical(node) {
|
|
3576
|
-
return node.right.type ===
|
|
4153
|
+
return node.right.type === AST_NODE_TYPES53.JSXElement || node.right.type === AST_NODE_TYPES53.JSXFragment;
|
|
3577
4154
|
}
|
|
3578
4155
|
function hasJSXReturn(block) {
|
|
3579
4156
|
return block.body.some((stmt) => {
|
|
3580
|
-
if (stmt.type ===
|
|
3581
|
-
return stmt.argument.type ===
|
|
4157
|
+
if (stmt.type === AST_NODE_TYPES53.ReturnStatement && stmt.argument) {
|
|
4158
|
+
return stmt.argument.type === AST_NODE_TYPES53.JSXElement || stmt.argument.type === AST_NODE_TYPES53.JSXFragment || stmt.argument.type === AST_NODE_TYPES53.ConditionalExpression && hasJSXInConditional(stmt.argument) || stmt.argument.type === AST_NODE_TYPES53.LogicalExpression && hasJSXInLogical(stmt.argument);
|
|
3582
4159
|
}
|
|
3583
4160
|
return false;
|
|
3584
4161
|
});
|
|
3585
4162
|
}
|
|
3586
4163
|
function isReactComponent2(node) {
|
|
3587
|
-
if (node.type ===
|
|
3588
|
-
if (node.body.type ===
|
|
4164
|
+
if (node.type === AST_NODE_TYPES53.ArrowFunctionExpression) {
|
|
4165
|
+
if (node.body.type === AST_NODE_TYPES53.JSXElement || node.body.type === AST_NODE_TYPES53.JSXFragment) {
|
|
3589
4166
|
return true;
|
|
3590
4167
|
}
|
|
3591
|
-
if (node.body.type ===
|
|
4168
|
+
if (node.body.type === AST_NODE_TYPES53.BlockStatement) {
|
|
3592
4169
|
return hasJSXReturn(node.body);
|
|
3593
4170
|
}
|
|
3594
|
-
} else if (node.type ===
|
|
3595
|
-
if (node.body && node.body.type ===
|
|
4171
|
+
} else if (node.type === AST_NODE_TYPES53.FunctionExpression || node.type === AST_NODE_TYPES53.FunctionDeclaration) {
|
|
4172
|
+
if (node.body && node.body.type === AST_NODE_TYPES53.BlockStatement) {
|
|
3596
4173
|
return hasJSXReturn(node.body);
|
|
3597
4174
|
}
|
|
3598
4175
|
}
|
|
3599
4176
|
return false;
|
|
3600
4177
|
}
|
|
3601
4178
|
function isInlineTypeAnnotation(node) {
|
|
3602
|
-
if (node.type ===
|
|
4179
|
+
if (node.type === AST_NODE_TYPES53.TSTypeLiteral) {
|
|
3603
4180
|
return true;
|
|
3604
4181
|
}
|
|
3605
|
-
if (node.type ===
|
|
3606
|
-
return node.typeArguments.params.some((param) => param.type ===
|
|
4182
|
+
if (node.type === AST_NODE_TYPES53.TSTypeReference && node.typeArguments) {
|
|
4183
|
+
return node.typeArguments.params.some((param) => param.type === AST_NODE_TYPES53.TSTypeLiteral);
|
|
3607
4184
|
}
|
|
3608
|
-
if (node.type ===
|
|
4185
|
+
if (node.type === AST_NODE_TYPES53.TSUnionType) {
|
|
3609
4186
|
return node.types.some((type) => isInlineTypeAnnotation(type));
|
|
3610
4187
|
}
|
|
3611
4188
|
return false;
|
|
3612
4189
|
}
|
|
3613
4190
|
function hasInlineObjectType(node) {
|
|
3614
|
-
if (node.type ===
|
|
4191
|
+
if (node.type === AST_NODE_TYPES53.TSTypeLiteral) {
|
|
3615
4192
|
return true;
|
|
3616
4193
|
}
|
|
3617
|
-
if (node.type ===
|
|
3618
|
-
return node.typeArguments.params.some((param) => param.type ===
|
|
4194
|
+
if (node.type === AST_NODE_TYPES53.TSTypeReference && node.typeArguments) {
|
|
4195
|
+
return node.typeArguments.params.some((param) => param.type === AST_NODE_TYPES53.TSTypeLiteral);
|
|
3619
4196
|
}
|
|
3620
|
-
if (node.type ===
|
|
4197
|
+
if (node.type === AST_NODE_TYPES53.TSUnionType) {
|
|
3621
4198
|
return node.types.some((type) => hasInlineObjectType(type));
|
|
3622
4199
|
}
|
|
3623
4200
|
return false;
|
|
@@ -3630,7 +4207,7 @@ var preferInterfaceOverInlineTypes = createRule47({
|
|
|
3630
4207
|
return;
|
|
3631
4208
|
}
|
|
3632
4209
|
const param = node.params[0];
|
|
3633
|
-
if (param.type ===
|
|
4210
|
+
if (param.type === AST_NODE_TYPES53.Identifier && param.typeAnnotation) {
|
|
3634
4211
|
const { typeAnnotation } = param.typeAnnotation;
|
|
3635
4212
|
if (isInlineTypeAnnotation(typeAnnotation) && hasInlineObjectType(typeAnnotation)) {
|
|
3636
4213
|
context.report({
|
|
@@ -3650,11 +4227,11 @@ var preferInterfaceOverInlineTypes = createRule47({
|
|
|
3650
4227
|
var prefer_interface_over_inline_types_default = preferInterfaceOverInlineTypes;
|
|
3651
4228
|
|
|
3652
4229
|
// src/rules/prefer-jsx-template-literals.ts
|
|
3653
|
-
import { AST_NODE_TYPES as
|
|
3654
|
-
var
|
|
4230
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES54, ESLintUtils as ESLintUtils54 } from "@typescript-eslint/utils";
|
|
4231
|
+
var createRule54 = ESLintUtils54.RuleCreator(
|
|
3655
4232
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3656
4233
|
);
|
|
3657
|
-
var preferJSXTemplateLiterals =
|
|
4234
|
+
var preferJSXTemplateLiterals = createRule54({
|
|
3658
4235
|
name: "prefer-jsx-template-literals",
|
|
3659
4236
|
meta: {
|
|
3660
4237
|
type: "suggestion",
|
|
@@ -3723,9 +4300,9 @@ var preferJSXTemplateLiterals = createRule48({
|
|
|
3723
4300
|
if (!child || !nextChild) {
|
|
3724
4301
|
return;
|
|
3725
4302
|
}
|
|
3726
|
-
if (child.type ===
|
|
4303
|
+
if (child.type === AST_NODE_TYPES54.JSXText && nextChild.type === AST_NODE_TYPES54.JSXExpressionContainer) {
|
|
3727
4304
|
handleTextBeforeExpression(child, nextChild);
|
|
3728
|
-
} else if (child.type ===
|
|
4305
|
+
} else if (child.type === AST_NODE_TYPES54.JSXExpressionContainer && nextChild.type === AST_NODE_TYPES54.JSXText) {
|
|
3729
4306
|
handleExpressionBeforeText(child, nextChild);
|
|
3730
4307
|
}
|
|
3731
4308
|
}
|
|
@@ -3738,32 +4315,32 @@ var preferJSXTemplateLiterals = createRule48({
|
|
|
3738
4315
|
var prefer_jsx_template_literals_default = preferJSXTemplateLiterals;
|
|
3739
4316
|
|
|
3740
4317
|
// src/rules/prefer-named-param-types.ts
|
|
3741
|
-
import { AST_NODE_TYPES as
|
|
3742
|
-
var
|
|
4318
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES55, ESLintUtils as ESLintUtils55 } from "@typescript-eslint/utils";
|
|
4319
|
+
var createRule55 = ESLintUtils55.RuleCreator(
|
|
3743
4320
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3744
4321
|
);
|
|
3745
4322
|
var returnsJsx2 = (node) => {
|
|
3746
|
-
if (node.type ===
|
|
4323
|
+
if (node.type === AST_NODE_TYPES55.JSXElement || node.type === AST_NODE_TYPES55.JSXFragment) {
|
|
3747
4324
|
return true;
|
|
3748
4325
|
}
|
|
3749
|
-
if (node.type ===
|
|
4326
|
+
if (node.type === AST_NODE_TYPES55.ConditionalExpression) {
|
|
3750
4327
|
return returnsJsx2(node.consequent) || returnsJsx2(node.alternate);
|
|
3751
4328
|
}
|
|
3752
|
-
if (node.type ===
|
|
4329
|
+
if (node.type === AST_NODE_TYPES55.LogicalExpression) {
|
|
3753
4330
|
return returnsJsx2(node.left) || returnsJsx2(node.right);
|
|
3754
4331
|
}
|
|
3755
4332
|
return false;
|
|
3756
4333
|
};
|
|
3757
4334
|
var bodyReturnsJsx2 = (body) => {
|
|
3758
|
-
if (body.type !==
|
|
4335
|
+
if (body.type !== AST_NODE_TYPES55.BlockStatement) {
|
|
3759
4336
|
return returnsJsx2(body);
|
|
3760
4337
|
}
|
|
3761
4338
|
return body.body.some(
|
|
3762
|
-
(stmt) => stmt.type ===
|
|
4339
|
+
(stmt) => stmt.type === AST_NODE_TYPES55.ReturnStatement && stmt.argument !== null && returnsJsx2(stmt.argument)
|
|
3763
4340
|
);
|
|
3764
4341
|
};
|
|
3765
4342
|
var isReactComponentFunction = (node) => bodyReturnsJsx2(node.body);
|
|
3766
|
-
var preferNamedParamTypes =
|
|
4343
|
+
var preferNamedParamTypes = createRule55({
|
|
3767
4344
|
name: "prefer-named-param-types",
|
|
3768
4345
|
meta: {
|
|
3769
4346
|
type: "suggestion",
|
|
@@ -3778,16 +4355,16 @@ var preferNamedParamTypes = createRule49({
|
|
|
3778
4355
|
defaultOptions: [],
|
|
3779
4356
|
create(context) {
|
|
3780
4357
|
function hasInlineObjectType(param) {
|
|
3781
|
-
if (param.type ===
|
|
4358
|
+
if (param.type === AST_NODE_TYPES55.AssignmentPattern) {
|
|
3782
4359
|
return hasInlineObjectType(param.left);
|
|
3783
4360
|
}
|
|
3784
|
-
if (param.type ===
|
|
3785
|
-
if (param.typeAnnotation?.typeAnnotation.type ===
|
|
4361
|
+
if (param.type === AST_NODE_TYPES55.ObjectPattern) {
|
|
4362
|
+
if (param.typeAnnotation?.typeAnnotation.type === AST_NODE_TYPES55.TSTypeLiteral) {
|
|
3786
4363
|
return true;
|
|
3787
4364
|
}
|
|
3788
4365
|
}
|
|
3789
|
-
if (param.type ===
|
|
3790
|
-
if (param.typeAnnotation?.typeAnnotation.type ===
|
|
4366
|
+
if (param.type === AST_NODE_TYPES55.Identifier) {
|
|
4367
|
+
if (param.typeAnnotation?.typeAnnotation.type === AST_NODE_TYPES55.TSTypeLiteral) {
|
|
3791
4368
|
return true;
|
|
3792
4369
|
}
|
|
3793
4370
|
}
|
|
@@ -3800,7 +4377,7 @@ var preferNamedParamTypes = createRule49({
|
|
|
3800
4377
|
} else if ("value" in node && node.value) {
|
|
3801
4378
|
params = node.value.params;
|
|
3802
4379
|
}
|
|
3803
|
-
if ((node.type ===
|
|
4380
|
+
if ((node.type === AST_NODE_TYPES55.FunctionDeclaration || node.type === AST_NODE_TYPES55.FunctionExpression || node.type === AST_NODE_TYPES55.ArrowFunctionExpression) && params.length === 1 && params[0].type === AST_NODE_TYPES55.Identifier && isReactComponentFunction(node)) {
|
|
3804
4381
|
return;
|
|
3805
4382
|
}
|
|
3806
4383
|
params.forEach((param) => {
|
|
@@ -3824,11 +4401,11 @@ var preferNamedParamTypes = createRule49({
|
|
|
3824
4401
|
var prefer_named_param_types_default = preferNamedParamTypes;
|
|
3825
4402
|
|
|
3826
4403
|
// src/rules/prefer-props-with-children.ts
|
|
3827
|
-
import { AST_NODE_TYPES as
|
|
3828
|
-
var
|
|
4404
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES56, ESLintUtils as ESLintUtils56 } from "@typescript-eslint/utils";
|
|
4405
|
+
var createRule56 = ESLintUtils56.RuleCreator(
|
|
3829
4406
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3830
4407
|
);
|
|
3831
|
-
var preferPropsWithChildren =
|
|
4408
|
+
var preferPropsWithChildren = createRule56({
|
|
3832
4409
|
name: "prefer-props-with-children",
|
|
3833
4410
|
meta: {
|
|
3834
4411
|
type: "suggestion",
|
|
@@ -3846,24 +4423,24 @@ var preferPropsWithChildren = createRule50({
|
|
|
3846
4423
|
if (!typeNode) {
|
|
3847
4424
|
return false;
|
|
3848
4425
|
}
|
|
3849
|
-
if (typeNode.type !==
|
|
4426
|
+
if (typeNode.type !== AST_NODE_TYPES56.TSTypeReference) {
|
|
3850
4427
|
return false;
|
|
3851
4428
|
}
|
|
3852
4429
|
const { typeName } = typeNode;
|
|
3853
|
-
if (typeName.type ===
|
|
4430
|
+
if (typeName.type === AST_NODE_TYPES56.Identifier) {
|
|
3854
4431
|
return typeName.name === "ReactNode";
|
|
3855
4432
|
}
|
|
3856
|
-
if (typeName.type ===
|
|
4433
|
+
if (typeName.type === AST_NODE_TYPES56.TSQualifiedName && typeName.left.type === AST_NODE_TYPES56.Identifier && typeName.left.name === "React" && typeName.right.type === AST_NODE_TYPES56.Identifier && typeName.right.name === "ReactNode") {
|
|
3857
4434
|
return true;
|
|
3858
4435
|
}
|
|
3859
4436
|
return false;
|
|
3860
4437
|
}
|
|
3861
4438
|
function findChildrenReactNode(members) {
|
|
3862
4439
|
for (const member of members) {
|
|
3863
|
-
if (member.type !==
|
|
4440
|
+
if (member.type !== AST_NODE_TYPES56.TSPropertySignature) {
|
|
3864
4441
|
continue;
|
|
3865
4442
|
}
|
|
3866
|
-
if (member.key.type !==
|
|
4443
|
+
if (member.key.type !== AST_NODE_TYPES56.Identifier) {
|
|
3867
4444
|
continue;
|
|
3868
4445
|
}
|
|
3869
4446
|
if (member.key.name !== "children") {
|
|
@@ -3903,11 +4480,11 @@ var preferPropsWithChildren = createRule50({
|
|
|
3903
4480
|
var prefer_props_with_children_default = preferPropsWithChildren;
|
|
3904
4481
|
|
|
3905
4482
|
// src/rules/prefer-react-import-types.ts
|
|
3906
|
-
import { AST_NODE_TYPES as
|
|
3907
|
-
var
|
|
4483
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES57, ESLintUtils as ESLintUtils57 } from "@typescript-eslint/utils";
|
|
4484
|
+
var createRule57 = ESLintUtils57.RuleCreator(
|
|
3908
4485
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3909
4486
|
);
|
|
3910
|
-
var preferReactImportTypes =
|
|
4487
|
+
var preferReactImportTypes = createRule57({
|
|
3911
4488
|
name: "prefer-react-import-types",
|
|
3912
4489
|
meta: {
|
|
3913
4490
|
type: "suggestion",
|
|
@@ -3983,7 +4560,7 @@ var preferReactImportTypes = createRule51({
|
|
|
3983
4560
|
]);
|
|
3984
4561
|
const allReactExports = /* @__PURE__ */ new Set([...reactTypes, ...reactRuntimeExports]);
|
|
3985
4562
|
function checkMemberExpression(node) {
|
|
3986
|
-
if (node.object.type ===
|
|
4563
|
+
if (node.object.type === AST_NODE_TYPES57.Identifier && node.object.name === "React" && node.property.type === AST_NODE_TYPES57.Identifier && allReactExports.has(node.property.name)) {
|
|
3987
4564
|
const typeName = node.property.name;
|
|
3988
4565
|
const isType = reactTypes.has(typeName);
|
|
3989
4566
|
const importStatement = isType ? `import type { ${typeName} } from "react"` : `import { ${typeName} } from "react"`;
|
|
@@ -4000,7 +4577,7 @@ var preferReactImportTypes = createRule51({
|
|
|
4000
4577
|
return {
|
|
4001
4578
|
MemberExpression: checkMemberExpression,
|
|
4002
4579
|
"TSTypeReference > TSQualifiedName": (node) => {
|
|
4003
|
-
if (node.left.type ===
|
|
4580
|
+
if (node.left.type === AST_NODE_TYPES57.Identifier && node.left.name === "React" && node.right.type === AST_NODE_TYPES57.Identifier && allReactExports.has(node.right.name)) {
|
|
4004
4581
|
const typeName = node.right.name;
|
|
4005
4582
|
const isType = reactTypes.has(typeName);
|
|
4006
4583
|
const importStatement = isType ? `import type { ${typeName} } from "react"` : `import { ${typeName} } from "react"`;
|
|
@@ -4020,11 +4597,11 @@ var preferReactImportTypes = createRule51({
|
|
|
4020
4597
|
var prefer_react_import_types_default = preferReactImportTypes;
|
|
4021
4598
|
|
|
4022
4599
|
// src/rules/react-props-destructure.ts
|
|
4023
|
-
import { AST_NODE_TYPES as
|
|
4024
|
-
var
|
|
4600
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES58, ESLintUtils as ESLintUtils58 } from "@typescript-eslint/utils";
|
|
4601
|
+
var createRule58 = ESLintUtils58.RuleCreator(
|
|
4025
4602
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
4026
4603
|
);
|
|
4027
|
-
var reactPropsDestructure =
|
|
4604
|
+
var reactPropsDestructure = createRule58({
|
|
4028
4605
|
name: "react-props-destructure",
|
|
4029
4606
|
meta: {
|
|
4030
4607
|
type: "suggestion",
|
|
@@ -4040,29 +4617,29 @@ var reactPropsDestructure = createRule52({
|
|
|
4040
4617
|
defaultOptions: [],
|
|
4041
4618
|
create(context) {
|
|
4042
4619
|
function hasJSXInConditional(node) {
|
|
4043
|
-
return node.consequent.type ===
|
|
4620
|
+
return node.consequent.type === AST_NODE_TYPES58.JSXElement || node.consequent.type === AST_NODE_TYPES58.JSXFragment || node.alternate.type === AST_NODE_TYPES58.JSXElement || node.alternate.type === AST_NODE_TYPES58.JSXFragment;
|
|
4044
4621
|
}
|
|
4045
4622
|
function hasJSXInLogical(node) {
|
|
4046
|
-
return node.right.type ===
|
|
4623
|
+
return node.right.type === AST_NODE_TYPES58.JSXElement || node.right.type === AST_NODE_TYPES58.JSXFragment;
|
|
4047
4624
|
}
|
|
4048
4625
|
function hasJSXReturn(block) {
|
|
4049
4626
|
return block.body.some((stmt) => {
|
|
4050
|
-
if (stmt.type ===
|
|
4051
|
-
return stmt.argument.type ===
|
|
4627
|
+
if (stmt.type === AST_NODE_TYPES58.ReturnStatement && stmt.argument) {
|
|
4628
|
+
return stmt.argument.type === AST_NODE_TYPES58.JSXElement || stmt.argument.type === AST_NODE_TYPES58.JSXFragment || stmt.argument.type === AST_NODE_TYPES58.ConditionalExpression && hasJSXInConditional(stmt.argument) || stmt.argument.type === AST_NODE_TYPES58.LogicalExpression && hasJSXInLogical(stmt.argument);
|
|
4052
4629
|
}
|
|
4053
4630
|
return false;
|
|
4054
4631
|
});
|
|
4055
4632
|
}
|
|
4056
4633
|
function isReactComponent2(node) {
|
|
4057
|
-
if (node.type ===
|
|
4058
|
-
if (node.body.type ===
|
|
4634
|
+
if (node.type === AST_NODE_TYPES58.ArrowFunctionExpression) {
|
|
4635
|
+
if (node.body.type === AST_NODE_TYPES58.JSXElement || node.body.type === AST_NODE_TYPES58.JSXFragment) {
|
|
4059
4636
|
return true;
|
|
4060
4637
|
}
|
|
4061
|
-
if (node.body.type ===
|
|
4638
|
+
if (node.body.type === AST_NODE_TYPES58.BlockStatement) {
|
|
4062
4639
|
return hasJSXReturn(node.body);
|
|
4063
4640
|
}
|
|
4064
|
-
} else if (node.type ===
|
|
4065
|
-
if (node.body && node.body.type ===
|
|
4641
|
+
} else if (node.type === AST_NODE_TYPES58.FunctionExpression || node.type === AST_NODE_TYPES58.FunctionDeclaration) {
|
|
4642
|
+
if (node.body && node.body.type === AST_NODE_TYPES58.BlockStatement) {
|
|
4066
4643
|
return hasJSXReturn(node.body);
|
|
4067
4644
|
}
|
|
4068
4645
|
}
|
|
@@ -4076,9 +4653,9 @@ var reactPropsDestructure = createRule52({
|
|
|
4076
4653
|
return;
|
|
4077
4654
|
}
|
|
4078
4655
|
const param = node.params[0];
|
|
4079
|
-
if (param.type ===
|
|
4080
|
-
const properties = param.properties.filter((prop) => prop.type ===
|
|
4081
|
-
if (prop.key.type ===
|
|
4656
|
+
if (param.type === AST_NODE_TYPES58.ObjectPattern) {
|
|
4657
|
+
const properties = param.properties.filter((prop) => prop.type === AST_NODE_TYPES58.Property).map((prop) => {
|
|
4658
|
+
if (prop.key.type === AST_NODE_TYPES58.Identifier) {
|
|
4082
4659
|
return prop.key.name;
|
|
4083
4660
|
}
|
|
4084
4661
|
return null;
|
|
@@ -4105,57 +4682,57 @@ var reactPropsDestructure = createRule52({
|
|
|
4105
4682
|
var react_props_destructure_default = reactPropsDestructure;
|
|
4106
4683
|
|
|
4107
4684
|
// src/rules/require-explicit-return-type.ts
|
|
4108
|
-
import { AST_NODE_TYPES as
|
|
4109
|
-
var
|
|
4685
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES59, ESLintUtils as ESLintUtils59 } from "@typescript-eslint/utils";
|
|
4686
|
+
var createRule59 = ESLintUtils59.RuleCreator(
|
|
4110
4687
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
4111
4688
|
);
|
|
4112
4689
|
var isReactComponent = (node) => {
|
|
4113
|
-
if (node.type ===
|
|
4690
|
+
if (node.type === AST_NODE_TYPES59.ArrowFunctionExpression) {
|
|
4114
4691
|
const { parent } = node;
|
|
4115
|
-
if (parent?.type ===
|
|
4692
|
+
if (parent?.type === AST_NODE_TYPES59.VariableDeclarator) {
|
|
4116
4693
|
const { id } = parent;
|
|
4117
|
-
if (id.type ===
|
|
4694
|
+
if (id.type === AST_NODE_TYPES59.Identifier) {
|
|
4118
4695
|
return /^[A-Z]/.test(id.name);
|
|
4119
4696
|
}
|
|
4120
4697
|
}
|
|
4121
4698
|
}
|
|
4122
|
-
if (node.type ===
|
|
4699
|
+
if (node.type === AST_NODE_TYPES59.FunctionDeclaration && node.id) {
|
|
4123
4700
|
return /^[A-Z]/.test(node.id.name);
|
|
4124
4701
|
}
|
|
4125
4702
|
return false;
|
|
4126
4703
|
};
|
|
4127
4704
|
var isCallbackFunction = (node) => {
|
|
4128
|
-
if (node.type ===
|
|
4705
|
+
if (node.type === AST_NODE_TYPES59.FunctionDeclaration) {
|
|
4129
4706
|
return false;
|
|
4130
4707
|
}
|
|
4131
4708
|
const { parent } = node;
|
|
4132
4709
|
if (!parent) {
|
|
4133
4710
|
return false;
|
|
4134
4711
|
}
|
|
4135
|
-
if (parent.type ===
|
|
4712
|
+
if (parent.type === AST_NODE_TYPES59.CallExpression && parent.arguments.includes(node)) {
|
|
4136
4713
|
return true;
|
|
4137
4714
|
}
|
|
4138
|
-
if (parent.type ===
|
|
4715
|
+
if (parent.type === AST_NODE_TYPES59.Property) {
|
|
4139
4716
|
return true;
|
|
4140
4717
|
}
|
|
4141
|
-
if (parent.type ===
|
|
4718
|
+
if (parent.type === AST_NODE_TYPES59.ArrayExpression) {
|
|
4142
4719
|
return true;
|
|
4143
4720
|
}
|
|
4144
4721
|
return false;
|
|
4145
4722
|
};
|
|
4146
4723
|
var getFunctionName = (node) => {
|
|
4147
|
-
if (node.type ===
|
|
4724
|
+
if (node.type === AST_NODE_TYPES59.FunctionDeclaration && node.id) {
|
|
4148
4725
|
return node.id.name;
|
|
4149
4726
|
}
|
|
4150
|
-
if (node.type ===
|
|
4727
|
+
if (node.type === AST_NODE_TYPES59.FunctionExpression && node.id) {
|
|
4151
4728
|
return node.id.name;
|
|
4152
4729
|
}
|
|
4153
|
-
if ((node.type ===
|
|
4730
|
+
if ((node.type === AST_NODE_TYPES59.ArrowFunctionExpression || node.type === AST_NODE_TYPES59.FunctionExpression) && node.parent?.type === AST_NODE_TYPES59.VariableDeclarator && node.parent.id.type === AST_NODE_TYPES59.Identifier) {
|
|
4154
4731
|
return node.parent.id.name;
|
|
4155
4732
|
}
|
|
4156
4733
|
return null;
|
|
4157
4734
|
};
|
|
4158
|
-
var requireExplicitReturnType =
|
|
4735
|
+
var requireExplicitReturnType = createRule59({
|
|
4159
4736
|
name: "require-explicit-return-type",
|
|
4160
4737
|
meta: {
|
|
4161
4738
|
type: "suggestion",
|
|
@@ -4204,8 +4781,8 @@ var requireExplicitReturnType = createRule53({
|
|
|
4204
4781
|
var require_explicit_return_type_default = requireExplicitReturnType;
|
|
4205
4782
|
|
|
4206
4783
|
// src/rules/sort-exports.ts
|
|
4207
|
-
import { AST_NODE_TYPES as
|
|
4208
|
-
var
|
|
4784
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES60, ESLintUtils as ESLintUtils60 } from "@typescript-eslint/utils";
|
|
4785
|
+
var createRule60 = ESLintUtils60.RuleCreator(
|
|
4209
4786
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
4210
4787
|
);
|
|
4211
4788
|
var GROUP_NAMES = ["", "external/alias re-export", "relative re-export", "local export"];
|
|
@@ -4219,7 +4796,7 @@ function getExportGroup(node) {
|
|
|
4219
4796
|
}
|
|
4220
4797
|
return 1;
|
|
4221
4798
|
}
|
|
4222
|
-
var sortExports =
|
|
4799
|
+
var sortExports = createRule60({
|
|
4223
4800
|
name: "sort-exports",
|
|
4224
4801
|
meta: {
|
|
4225
4802
|
type: "suggestion",
|
|
@@ -4259,7 +4836,7 @@ var sortExports = createRule54({
|
|
|
4259
4836
|
Program(node) {
|
|
4260
4837
|
const exportGroups = [];
|
|
4261
4838
|
node.body.forEach((statement) => {
|
|
4262
|
-
if (statement.type !==
|
|
4839
|
+
if (statement.type !== AST_NODE_TYPES60.ExportNamedDeclaration || statement.declaration !== null) {
|
|
4263
4840
|
if (exportGroups.length > 0) {
|
|
4264
4841
|
checkOrder(exportGroups);
|
|
4265
4842
|
exportGroups.length = 0;
|
|
@@ -4278,8 +4855,8 @@ var sortExports = createRule54({
|
|
|
4278
4855
|
var sort_exports_default = sortExports;
|
|
4279
4856
|
|
|
4280
4857
|
// src/rules/sort-imports.ts
|
|
4281
|
-
import { AST_NODE_TYPES as
|
|
4282
|
-
var
|
|
4858
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES61, ESLintUtils as ESLintUtils61 } from "@typescript-eslint/utils";
|
|
4859
|
+
var createRule61 = ESLintUtils61.RuleCreator(
|
|
4283
4860
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
4284
4861
|
);
|
|
4285
4862
|
var NODE_BUILTINS = /* @__PURE__ */ new Set([
|
|
@@ -4346,7 +4923,7 @@ function getImportGroup(node) {
|
|
|
4346
4923
|
function isTypeOnlyImport(node) {
|
|
4347
4924
|
return node.importKind === "type" && node.specifiers.length > 0;
|
|
4348
4925
|
}
|
|
4349
|
-
var sortImports =
|
|
4926
|
+
var sortImports = createRule61({
|
|
4350
4927
|
name: "sort-imports",
|
|
4351
4928
|
meta: {
|
|
4352
4929
|
type: "suggestion",
|
|
@@ -4390,7 +4967,7 @@ var sortImports = createRule55({
|
|
|
4390
4967
|
Program(node) {
|
|
4391
4968
|
const importGroups = [];
|
|
4392
4969
|
node.body.forEach((statement) => {
|
|
4393
|
-
if (statement.type !==
|
|
4970
|
+
if (statement.type !== AST_NODE_TYPES61.ImportDeclaration) {
|
|
4394
4971
|
if (importGroups.length > 0) {
|
|
4395
4972
|
checkOrder(importGroups);
|
|
4396
4973
|
importGroups.length = 0;
|
|
@@ -4412,13 +4989,13 @@ var sortImports = createRule55({
|
|
|
4412
4989
|
var sort_imports_default = sortImports;
|
|
4413
4990
|
|
|
4414
4991
|
// src/rules/sort-type-alphabetically.ts
|
|
4415
|
-
import { AST_NODE_TYPES as
|
|
4416
|
-
var
|
|
4992
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES62, ESLintUtils as ESLintUtils62 } from "@typescript-eslint/utils";
|
|
4993
|
+
var createRule62 = ESLintUtils62.RuleCreator(
|
|
4417
4994
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
4418
4995
|
);
|
|
4419
4996
|
function isAlphabeticallySortedWithinGroups(members) {
|
|
4420
4997
|
const properties = members.filter(
|
|
4421
|
-
(member) => member.type ===
|
|
4998
|
+
(member) => member.type === AST_NODE_TYPES62.TSPropertySignature && member.key.type === AST_NODE_TYPES62.Identifier
|
|
4422
4999
|
);
|
|
4423
5000
|
if (properties.length < 2) {
|
|
4424
5001
|
return true;
|
|
@@ -4429,7 +5006,7 @@ function isAlphabeticallySortedWithinGroups(members) {
|
|
|
4429
5006
|
const isOptionalSorted = optional.every((name, index) => index === 0 || optional[index - 1].localeCompare(name) <= 0);
|
|
4430
5007
|
return isRequiredSorted && isOptionalSorted;
|
|
4431
5008
|
}
|
|
4432
|
-
var sortTypeAlphabetically =
|
|
5009
|
+
var sortTypeAlphabetically = createRule62({
|
|
4433
5010
|
name: "sort-type-alphabetically",
|
|
4434
5011
|
meta: {
|
|
4435
5012
|
type: "suggestion",
|
|
@@ -4447,7 +5024,7 @@ var sortTypeAlphabetically = createRule56({
|
|
|
4447
5024
|
function fixMembers(fixer, members) {
|
|
4448
5025
|
const { sourceCode } = context;
|
|
4449
5026
|
const properties = members.filter(
|
|
4450
|
-
(member) => member.type ===
|
|
5027
|
+
(member) => member.type === AST_NODE_TYPES62.TSPropertySignature && member.key.type === AST_NODE_TYPES62.Identifier
|
|
4451
5028
|
);
|
|
4452
5029
|
const required = properties.filter((prop) => !prop.optional);
|
|
4453
5030
|
const optional = properties.filter((prop) => prop.optional);
|
|
@@ -4484,7 +5061,7 @@ var sortTypeAlphabetically = createRule56({
|
|
|
4484
5061
|
}
|
|
4485
5062
|
},
|
|
4486
5063
|
TSTypeAliasDeclaration(node) {
|
|
4487
|
-
if (node.typeAnnotation.type !==
|
|
5064
|
+
if (node.typeAnnotation.type !== AST_NODE_TYPES62.TSTypeLiteral) {
|
|
4488
5065
|
return;
|
|
4489
5066
|
}
|
|
4490
5067
|
const { members } = node.typeAnnotation;
|
|
@@ -4504,13 +5081,13 @@ var sortTypeAlphabetically = createRule56({
|
|
|
4504
5081
|
var sort_type_alphabetically_default = sortTypeAlphabetically;
|
|
4505
5082
|
|
|
4506
5083
|
// src/rules/sort-type-required-first.ts
|
|
4507
|
-
import { AST_NODE_TYPES as
|
|
4508
|
-
var
|
|
5084
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES63, ESLintUtils as ESLintUtils63 } from "@typescript-eslint/utils";
|
|
5085
|
+
var createRule63 = ESLintUtils63.RuleCreator(
|
|
4509
5086
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
4510
5087
|
);
|
|
4511
5088
|
function isRequiredBeforeOptional(members) {
|
|
4512
5089
|
const properties = members.filter(
|
|
4513
|
-
(member) => member.type ===
|
|
5090
|
+
(member) => member.type === AST_NODE_TYPES63.TSPropertySignature && member.key.type === AST_NODE_TYPES63.Identifier
|
|
4514
5091
|
);
|
|
4515
5092
|
if (properties.length < 2) {
|
|
4516
5093
|
return true;
|
|
@@ -4521,7 +5098,7 @@ function isRequiredBeforeOptional(members) {
|
|
|
4521
5098
|
}
|
|
4522
5099
|
return properties.slice(firstOptionalIndex).every((prop) => prop.optional);
|
|
4523
5100
|
}
|
|
4524
|
-
var sortTypeRequiredFirst =
|
|
5101
|
+
var sortTypeRequiredFirst = createRule63({
|
|
4525
5102
|
name: "sort-type-required-first",
|
|
4526
5103
|
meta: {
|
|
4527
5104
|
type: "suggestion",
|
|
@@ -4539,7 +5116,7 @@ var sortTypeRequiredFirst = createRule57({
|
|
|
4539
5116
|
function fixMembers(fixer, members) {
|
|
4540
5117
|
const { sourceCode } = context;
|
|
4541
5118
|
const properties = members.filter(
|
|
4542
|
-
(member) => member.type ===
|
|
5119
|
+
(member) => member.type === AST_NODE_TYPES63.TSPropertySignature && member.key.type === AST_NODE_TYPES63.Identifier
|
|
4543
5120
|
);
|
|
4544
5121
|
const required = properties.filter((prop) => !prop.optional);
|
|
4545
5122
|
const optional = properties.filter((prop) => prop.optional);
|
|
@@ -4560,7 +5137,7 @@ var sortTypeRequiredFirst = createRule57({
|
|
|
4560
5137
|
}
|
|
4561
5138
|
},
|
|
4562
5139
|
TSTypeAliasDeclaration(node) {
|
|
4563
|
-
if (node.typeAnnotation.type !==
|
|
5140
|
+
if (node.typeAnnotation.type !== AST_NODE_TYPES63.TSTypeLiteral) {
|
|
4564
5141
|
return;
|
|
4565
5142
|
}
|
|
4566
5143
|
const { members } = node.typeAnnotation;
|
|
@@ -4592,14 +5169,18 @@ var rules = {
|
|
|
4592
5169
|
"enforce-property-case": enforce_property_case_default,
|
|
4593
5170
|
"enforce-props-suffix": enforce_props_suffix_default,
|
|
4594
5171
|
"enforce-readonly-component-props": enforce_readonly_component_props_default,
|
|
5172
|
+
"enforce-render-naming": enforce_render_naming_default,
|
|
4595
5173
|
"enforce-service-naming": enforce_service_naming_default,
|
|
4596
5174
|
"enforce-sorted-destructuring": enforce_sorted_destructuring_default,
|
|
4597
5175
|
"enforce-type-declaration-order": enforce_type_declaration_order_default,
|
|
4598
5176
|
"index-export-only": index_export_only_default,
|
|
4599
5177
|
"jsx-newline-between-elements": jsx_newline_between_elements_default,
|
|
5178
|
+
"jsx-no-data-array": jsx_no_data_array_default,
|
|
5179
|
+
"jsx-no-data-object": jsx_no_data_object_default,
|
|
4600
5180
|
"jsx-no-inline-object-prop": jsx_no_inline_object_prop_default,
|
|
4601
5181
|
"jsx-no-newline-single-line-elements": jsx_no_newline_single_line_elements_default,
|
|
4602
5182
|
"jsx-no-non-component-function": jsx_no_non_component_function_default,
|
|
5183
|
+
"jsx-no-sub-interface": jsx_no_sub_interface_default,
|
|
4603
5184
|
"jsx-no-ternary-null": jsx_no_ternary_null_default,
|
|
4604
5185
|
"jsx-no-variable-in-callback": jsx_no_variable_in_callback_default,
|
|
4605
5186
|
"jsx-require-suspense": jsx_require_suspense_default,
|
|
@@ -4612,6 +5193,7 @@ var rules = {
|
|
|
4612
5193
|
"no-direct-date": no_direct_date_default,
|
|
4613
5194
|
"no-emoji": no_emoji_default,
|
|
4614
5195
|
"no-env-fallback": no_env_fallback_default,
|
|
5196
|
+
"no-ghost-wrapper": no_ghost_wrapper_default,
|
|
4615
5197
|
"no-inline-default-export": no_inline_default_export_default,
|
|
4616
5198
|
"no-inline-nested-object": no_inline_nested_object_default,
|
|
4617
5199
|
"no-inline-return-properties": no_inline_return_properties_default,
|
|
@@ -4621,6 +5203,7 @@ var rules = {
|
|
|
4621
5203
|
"no-misleading-constant-case": no_misleading_constant_case_default,
|
|
4622
5204
|
"no-nested-interface-declaration": no_nested_interface_declaration_default,
|
|
4623
5205
|
"no-nested-ternary": no_nested_ternary_default,
|
|
5206
|
+
"no-redundant-fragment": no_redundant_fragment_default,
|
|
4624
5207
|
"no-relative-imports": no_relative_imports_default,
|
|
4625
5208
|
"no-single-char-variables": no_single_char_variables_default,
|
|
4626
5209
|
"prefer-async-await": prefer_async_await_default,
|
|
@@ -4734,16 +5317,22 @@ var baseRecommendedRules = {
|
|
|
4734
5317
|
var jsxRules = {
|
|
4735
5318
|
"nextfriday/enforce-props-suffix": "warn",
|
|
4736
5319
|
"nextfriday/enforce-readonly-component-props": "warn",
|
|
5320
|
+
"nextfriday/enforce-render-naming": "warn",
|
|
4737
5321
|
"nextfriday/jsx-newline-between-elements": "warn",
|
|
5322
|
+
"nextfriday/jsx-no-data-array": "warn",
|
|
5323
|
+
"nextfriday/jsx-no-data-object": "warn",
|
|
4738
5324
|
"nextfriday/jsx-no-inline-object-prop": "warn",
|
|
4739
5325
|
"nextfriday/jsx-no-newline-single-line-elements": "warn",
|
|
4740
5326
|
"nextfriday/jsx-no-non-component-function": "warn",
|
|
5327
|
+
"nextfriday/jsx-no-sub-interface": "warn",
|
|
4741
5328
|
"nextfriday/jsx-no-ternary-null": "warn",
|
|
4742
5329
|
"nextfriday/jsx-no-variable-in-callback": "warn",
|
|
4743
5330
|
"nextfriday/jsx-require-suspense": "warn",
|
|
4744
5331
|
"nextfriday/jsx-simple-props": "warn",
|
|
4745
5332
|
"nextfriday/jsx-sort-props": "warn",
|
|
4746
5333
|
"nextfriday/jsx-spread-props-last": "warn",
|
|
5334
|
+
"nextfriday/no-ghost-wrapper": "warn",
|
|
5335
|
+
"nextfriday/no-redundant-fragment": "warn",
|
|
4747
5336
|
"nextfriday/prefer-interface-for-component-props": "warn",
|
|
4748
5337
|
"nextfriday/prefer-interface-over-inline-types": "warn",
|
|
4749
5338
|
"nextfriday/prefer-jsx-template-literals": "warn",
|
|
@@ -4753,16 +5342,22 @@ var jsxRules = {
|
|
|
4753
5342
|
var jsxRecommendedRules = {
|
|
4754
5343
|
"nextfriday/enforce-props-suffix": "error",
|
|
4755
5344
|
"nextfriday/enforce-readonly-component-props": "error",
|
|
5345
|
+
"nextfriday/enforce-render-naming": "error",
|
|
4756
5346
|
"nextfriday/jsx-newline-between-elements": "error",
|
|
5347
|
+
"nextfriday/jsx-no-data-array": "error",
|
|
5348
|
+
"nextfriday/jsx-no-data-object": "error",
|
|
4757
5349
|
"nextfriday/jsx-no-inline-object-prop": "error",
|
|
4758
5350
|
"nextfriday/jsx-no-newline-single-line-elements": "error",
|
|
4759
5351
|
"nextfriday/jsx-no-non-component-function": "error",
|
|
5352
|
+
"nextfriday/jsx-no-sub-interface": "error",
|
|
4760
5353
|
"nextfriday/jsx-no-ternary-null": "error",
|
|
4761
5354
|
"nextfriday/jsx-no-variable-in-callback": "error",
|
|
4762
5355
|
"nextfriday/jsx-require-suspense": "error",
|
|
4763
5356
|
"nextfriday/jsx-simple-props": "error",
|
|
4764
5357
|
"nextfriday/jsx-sort-props": "error",
|
|
4765
5358
|
"nextfriday/jsx-spread-props-last": "error",
|
|
5359
|
+
"nextfriday/no-ghost-wrapper": "error",
|
|
5360
|
+
"nextfriday/no-redundant-fragment": "error",
|
|
4766
5361
|
"nextfriday/prefer-interface-for-component-props": "error",
|
|
4767
5362
|
"nextfriday/prefer-interface-over-inline-types": "error",
|
|
4768
5363
|
"nextfriday/prefer-jsx-template-literals": "error",
|