eslint-plugin-nextfriday 4.1.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 +12 -0
- package/README.md +13 -5
- 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/lib/index.cjs +923 -454
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +168 -0
- package/lib/index.d.ts +168 -0
- package/lib/index.js +923 -454
- package/lib/index.js.map +1 -1
- package/package.json +1 -1
package/lib/index.cjs
CHANGED
|
@@ -40,7 +40,7 @@ module.exports = __toCommonJS(index_exports);
|
|
|
40
40
|
// package.json
|
|
41
41
|
var package_default = {
|
|
42
42
|
name: "eslint-plugin-nextfriday",
|
|
43
|
-
version: "4.
|
|
43
|
+
version: "4.2.0",
|
|
44
44
|
description: "A comprehensive ESLint plugin providing custom rules and configurations for Next Friday development workflows.",
|
|
45
45
|
keywords: [
|
|
46
46
|
"eslint",
|
|
@@ -804,18 +804,168 @@ var enforceReadonlyComponentProps = createRule7({
|
|
|
804
804
|
});
|
|
805
805
|
var enforce_readonly_component_props_default = enforceReadonlyComponentProps;
|
|
806
806
|
|
|
807
|
-
// src/rules/enforce-
|
|
807
|
+
// src/rules/enforce-render-naming.ts
|
|
808
808
|
var import_utils10 = require("@typescript-eslint/utils");
|
|
809
809
|
var createRule8 = import_utils10.ESLintUtils.RuleCreator(
|
|
810
810
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
811
811
|
);
|
|
812
|
+
var ARRAY_RETURNING_METHODS = /* @__PURE__ */ new Set(["map", "flatMap", "filter"]);
|
|
813
|
+
function hasRenderPrefix(name) {
|
|
814
|
+
if (!name.startsWith("render")) {
|
|
815
|
+
return false;
|
|
816
|
+
}
|
|
817
|
+
if (name.length === "render".length) {
|
|
818
|
+
return true;
|
|
819
|
+
}
|
|
820
|
+
const nextChar = name["render".length];
|
|
821
|
+
return nextChar === nextChar.toUpperCase() && nextChar !== nextChar.toLowerCase();
|
|
822
|
+
}
|
|
823
|
+
function functionBodyReturnsJsx(body) {
|
|
824
|
+
if (body.type === import_utils10.AST_NODE_TYPES.JSXElement || body.type === import_utils10.AST_NODE_TYPES.JSXFragment) {
|
|
825
|
+
return true;
|
|
826
|
+
}
|
|
827
|
+
if (body.type === import_utils10.AST_NODE_TYPES.ConditionalExpression) {
|
|
828
|
+
return isJsxProducingExpression(body.consequent) || isJsxProducingExpression(body.alternate);
|
|
829
|
+
}
|
|
830
|
+
if (body.type === import_utils10.AST_NODE_TYPES.LogicalExpression) {
|
|
831
|
+
return isJsxProducingExpression(body.right);
|
|
832
|
+
}
|
|
833
|
+
if (body.type !== import_utils10.AST_NODE_TYPES.BlockStatement) {
|
|
834
|
+
return false;
|
|
835
|
+
}
|
|
836
|
+
for (const statement of body.body) {
|
|
837
|
+
if (statement.type === import_utils10.AST_NODE_TYPES.ReturnStatement && statement.argument) {
|
|
838
|
+
if (isJsxProducingExpression(statement.argument)) {
|
|
839
|
+
return true;
|
|
840
|
+
}
|
|
841
|
+
}
|
|
842
|
+
}
|
|
843
|
+
return false;
|
|
844
|
+
}
|
|
845
|
+
function isJsxProducingExpression(node) {
|
|
846
|
+
if (node.type === import_utils10.AST_NODE_TYPES.JSXElement || node.type === import_utils10.AST_NODE_TYPES.JSXFragment) {
|
|
847
|
+
return true;
|
|
848
|
+
}
|
|
849
|
+
if (node.type === import_utils10.AST_NODE_TYPES.ConditionalExpression) {
|
|
850
|
+
return isJsxProducingExpression(node.consequent) || isJsxProducingExpression(node.alternate);
|
|
851
|
+
}
|
|
852
|
+
if (node.type === import_utils10.AST_NODE_TYPES.LogicalExpression) {
|
|
853
|
+
return isJsxProducingExpression(node.right);
|
|
854
|
+
}
|
|
855
|
+
if (node.type === import_utils10.AST_NODE_TYPES.ArrayExpression) {
|
|
856
|
+
return node.elements.some((element) => {
|
|
857
|
+
if (!element || element.type === import_utils10.AST_NODE_TYPES.SpreadElement) {
|
|
858
|
+
return false;
|
|
859
|
+
}
|
|
860
|
+
return isJsxProducingExpression(element);
|
|
861
|
+
});
|
|
862
|
+
}
|
|
863
|
+
if (node.type === import_utils10.AST_NODE_TYPES.ArrowFunctionExpression || node.type === import_utils10.AST_NODE_TYPES.FunctionExpression) {
|
|
864
|
+
return functionBodyReturnsJsx(node.body);
|
|
865
|
+
}
|
|
866
|
+
if (node.type === import_utils10.AST_NODE_TYPES.CallExpression) {
|
|
867
|
+
if (node.callee.type === import_utils10.AST_NODE_TYPES.MemberExpression && node.callee.property.type === import_utils10.AST_NODE_TYPES.Identifier && ARRAY_RETURNING_METHODS.has(node.callee.property.name)) {
|
|
868
|
+
const callback = node.arguments[0];
|
|
869
|
+
if (callback && (callback.type === import_utils10.AST_NODE_TYPES.ArrowFunctionExpression || callback.type === import_utils10.AST_NODE_TYPES.FunctionExpression)) {
|
|
870
|
+
return functionBodyReturnsJsx(callback.body);
|
|
871
|
+
}
|
|
872
|
+
}
|
|
873
|
+
}
|
|
874
|
+
if (node.type === import_utils10.AST_NODE_TYPES.TSAsExpression || node.type === import_utils10.AST_NODE_TYPES.TSSatisfiesExpression) {
|
|
875
|
+
return isJsxProducingExpression(node.expression);
|
|
876
|
+
}
|
|
877
|
+
return false;
|
|
878
|
+
}
|
|
879
|
+
function isPascalCase(name) {
|
|
880
|
+
return /^[A-Z]/.test(name);
|
|
881
|
+
}
|
|
882
|
+
function isComponentFunction2(node) {
|
|
883
|
+
if (node.type === import_utils10.AST_NODE_TYPES.FunctionDeclaration && node.id && isPascalCase(node.id.name)) {
|
|
884
|
+
return true;
|
|
885
|
+
}
|
|
886
|
+
const parent = node.parent;
|
|
887
|
+
if (parent?.type === import_utils10.AST_NODE_TYPES.VariableDeclarator && parent.id.type === import_utils10.AST_NODE_TYPES.Identifier && isPascalCase(parent.id.name)) {
|
|
888
|
+
return true;
|
|
889
|
+
}
|
|
890
|
+
return false;
|
|
891
|
+
}
|
|
892
|
+
var enforceRenderNaming = createRule8({
|
|
893
|
+
name: "enforce-render-naming",
|
|
894
|
+
meta: {
|
|
895
|
+
type: "problem",
|
|
896
|
+
docs: {
|
|
897
|
+
description: "Enforce 'render' prefix for variables that hold or return JSX inside React components"
|
|
898
|
+
},
|
|
899
|
+
schema: [],
|
|
900
|
+
messages: {
|
|
901
|
+
missingRenderPrefix: "Variable '{{ name }}' holds JSX-producing content inside a component. Rename it to 'render{{ pascalName }}' so the intent is explicit."
|
|
902
|
+
}
|
|
903
|
+
},
|
|
904
|
+
defaultOptions: [],
|
|
905
|
+
create(context) {
|
|
906
|
+
const { filename } = context;
|
|
907
|
+
const extension = getFileExtension(filename);
|
|
908
|
+
if (extension !== "tsx" && extension !== "jsx") {
|
|
909
|
+
return {};
|
|
910
|
+
}
|
|
911
|
+
const componentStack = [];
|
|
912
|
+
function isInsideComponent() {
|
|
913
|
+
return componentStack.some((value) => value);
|
|
914
|
+
}
|
|
915
|
+
function pushFunction(node) {
|
|
916
|
+
componentStack.push(isComponentFunction2(node));
|
|
917
|
+
}
|
|
918
|
+
function popFunction() {
|
|
919
|
+
componentStack.pop();
|
|
920
|
+
}
|
|
921
|
+
return {
|
|
922
|
+
ArrowFunctionExpression: pushFunction,
|
|
923
|
+
FunctionDeclaration: pushFunction,
|
|
924
|
+
FunctionExpression: pushFunction,
|
|
925
|
+
"ArrowFunctionExpression:exit": popFunction,
|
|
926
|
+
"FunctionDeclaration:exit": popFunction,
|
|
927
|
+
"FunctionExpression:exit": popFunction,
|
|
928
|
+
VariableDeclarator(node) {
|
|
929
|
+
if (!isInsideComponent()) {
|
|
930
|
+
return;
|
|
931
|
+
}
|
|
932
|
+
if (node.id.type !== import_utils10.AST_NODE_TYPES.Identifier) {
|
|
933
|
+
return;
|
|
934
|
+
}
|
|
935
|
+
if (!node.init) {
|
|
936
|
+
return;
|
|
937
|
+
}
|
|
938
|
+
if (!isJsxProducingExpression(node.init)) {
|
|
939
|
+
return;
|
|
940
|
+
}
|
|
941
|
+
const name = node.id.name;
|
|
942
|
+
if (hasRenderPrefix(name)) {
|
|
943
|
+
return;
|
|
944
|
+
}
|
|
945
|
+
const pascalName = name.charAt(0).toUpperCase() + name.slice(1);
|
|
946
|
+
context.report({
|
|
947
|
+
node: node.id,
|
|
948
|
+
messageId: "missingRenderPrefix",
|
|
949
|
+
data: { name, pascalName }
|
|
950
|
+
});
|
|
951
|
+
}
|
|
952
|
+
};
|
|
953
|
+
}
|
|
954
|
+
});
|
|
955
|
+
var enforce_render_naming_default = enforceRenderNaming;
|
|
956
|
+
|
|
957
|
+
// src/rules/enforce-service-naming.ts
|
|
958
|
+
var import_utils12 = require("@typescript-eslint/utils");
|
|
959
|
+
var createRule9 = import_utils12.ESLintUtils.RuleCreator(
|
|
960
|
+
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
961
|
+
);
|
|
812
962
|
var BANNED_PREFIXES = {
|
|
813
963
|
delete: ["remove", "archive"],
|
|
814
964
|
do: ["submit", "process"],
|
|
815
965
|
handle: ["create", "verify"],
|
|
816
966
|
set: ["update", "save", "patch"]
|
|
817
967
|
};
|
|
818
|
-
var enforceServiceNaming =
|
|
968
|
+
var enforceServiceNaming = createRule9({
|
|
819
969
|
name: "enforce-service-naming",
|
|
820
970
|
meta: {
|
|
821
971
|
type: "suggestion",
|
|
@@ -858,12 +1008,12 @@ var enforceServiceNaming = createRule8({
|
|
|
858
1008
|
};
|
|
859
1009
|
return {
|
|
860
1010
|
ExportNamedDeclaration(node) {
|
|
861
|
-
if (node.declaration?.type ===
|
|
1011
|
+
if (node.declaration?.type === import_utils12.AST_NODE_TYPES.FunctionDeclaration && node.declaration.id) {
|
|
862
1012
|
checkExportedFunction(node.declaration, node.declaration.id);
|
|
863
1013
|
}
|
|
864
|
-
if (node.declaration?.type ===
|
|
1014
|
+
if (node.declaration?.type === import_utils12.AST_NODE_TYPES.VariableDeclaration) {
|
|
865
1015
|
node.declaration.declarations.forEach((declarator) => {
|
|
866
|
-
if (declarator.id.type ===
|
|
1016
|
+
if (declarator.id.type === import_utils12.AST_NODE_TYPES.Identifier && declarator.init?.type === import_utils12.AST_NODE_TYPES.ArrowFunctionExpression) {
|
|
867
1017
|
checkExportedFunction(declarator.init, declarator.id);
|
|
868
1018
|
}
|
|
869
1019
|
});
|
|
@@ -875,11 +1025,11 @@ var enforceServiceNaming = createRule8({
|
|
|
875
1025
|
var enforce_service_naming_default = enforceServiceNaming;
|
|
876
1026
|
|
|
877
1027
|
// src/rules/enforce-sorted-destructuring.ts
|
|
878
|
-
var
|
|
879
|
-
var
|
|
1028
|
+
var import_utils13 = require("@typescript-eslint/utils");
|
|
1029
|
+
var createRule10 = import_utils13.ESLintUtils.RuleCreator(
|
|
880
1030
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
881
1031
|
);
|
|
882
|
-
var enforceSortedDestructuring =
|
|
1032
|
+
var enforceSortedDestructuring = createRule10({
|
|
883
1033
|
name: "enforce-sorted-destructuring",
|
|
884
1034
|
meta: {
|
|
885
1035
|
type: "suggestion",
|
|
@@ -895,19 +1045,19 @@ var enforceSortedDestructuring = createRule9({
|
|
|
895
1045
|
defaultOptions: [],
|
|
896
1046
|
create(context) {
|
|
897
1047
|
function getPropertyName(property) {
|
|
898
|
-
if (property.type ===
|
|
1048
|
+
if (property.type === import_utils13.AST_NODE_TYPES.RestElement) {
|
|
899
1049
|
return null;
|
|
900
1050
|
}
|
|
901
|
-
if (property.key.type ===
|
|
1051
|
+
if (property.key.type === import_utils13.AST_NODE_TYPES.Identifier) {
|
|
902
1052
|
return property.key.name;
|
|
903
1053
|
}
|
|
904
1054
|
return null;
|
|
905
1055
|
}
|
|
906
1056
|
function hasDefaultValue(property) {
|
|
907
|
-
return property.value.type ===
|
|
1057
|
+
return property.value.type === import_utils13.AST_NODE_TYPES.AssignmentPattern && Boolean(property.value.right);
|
|
908
1058
|
}
|
|
909
1059
|
function checkVariableDeclarator(node) {
|
|
910
|
-
if (node.id.type !==
|
|
1060
|
+
if (node.id.type !== import_utils13.AST_NODE_TYPES.ObjectPattern) {
|
|
911
1061
|
return;
|
|
912
1062
|
}
|
|
913
1063
|
const { properties } = node.id;
|
|
@@ -915,7 +1065,7 @@ var enforceSortedDestructuring = createRule9({
|
|
|
915
1065
|
return;
|
|
916
1066
|
}
|
|
917
1067
|
const propertyInfo = properties.map((prop) => {
|
|
918
|
-
if (prop.type ===
|
|
1068
|
+
if (prop.type === import_utils13.AST_NODE_TYPES.RestElement) {
|
|
919
1069
|
return null;
|
|
920
1070
|
}
|
|
921
1071
|
return {
|
|
@@ -954,20 +1104,20 @@ var enforceSortedDestructuring = createRule9({
|
|
|
954
1104
|
var enforce_sorted_destructuring_default = enforceSortedDestructuring;
|
|
955
1105
|
|
|
956
1106
|
// src/rules/enforce-type-declaration-order.ts
|
|
957
|
-
var
|
|
958
|
-
var
|
|
1107
|
+
var import_utils14 = require("@typescript-eslint/utils");
|
|
1108
|
+
var createRule11 = import_utils14.ESLintUtils.RuleCreator(
|
|
959
1109
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
960
1110
|
);
|
|
961
1111
|
function getTypeDeclarationName(node) {
|
|
962
|
-
if (node.type ===
|
|
1112
|
+
if (node.type === import_utils14.AST_NODE_TYPES.TSInterfaceDeclaration && node.id.type === import_utils14.AST_NODE_TYPES.Identifier) {
|
|
963
1113
|
return { name: node.id.name, position: node.range[0] };
|
|
964
1114
|
}
|
|
965
|
-
if (node.type ===
|
|
1115
|
+
if (node.type === import_utils14.AST_NODE_TYPES.TSTypeAliasDeclaration && node.id.type === import_utils14.AST_NODE_TYPES.Identifier) {
|
|
966
1116
|
return { name: node.id.name, position: node.range[0] };
|
|
967
1117
|
}
|
|
968
1118
|
return null;
|
|
969
1119
|
}
|
|
970
|
-
var enforceTypeDeclarationOrder =
|
|
1120
|
+
var enforceTypeDeclarationOrder = createRule11({
|
|
971
1121
|
name: "enforce-type-declaration-order",
|
|
972
1122
|
meta: {
|
|
973
1123
|
type: "suggestion",
|
|
@@ -998,7 +1148,7 @@ var enforceTypeDeclarationOrder = createRule10({
|
|
|
998
1148
|
}
|
|
999
1149
|
},
|
|
1000
1150
|
"TSPropertySignature TSTypeReference": function checkTypeReference(node) {
|
|
1001
|
-
if (node.typeName.type !==
|
|
1151
|
+
if (node.typeName.type !== import_utils14.AST_NODE_TYPES.Identifier) {
|
|
1002
1152
|
return;
|
|
1003
1153
|
}
|
|
1004
1154
|
const referencedName = node.typeName.name;
|
|
@@ -1035,8 +1185,8 @@ var enforceTypeDeclarationOrder = createRule10({
|
|
|
1035
1185
|
var enforce_type_declaration_order_default = enforceTypeDeclarationOrder;
|
|
1036
1186
|
|
|
1037
1187
|
// src/rules/index-export-only.ts
|
|
1038
|
-
var
|
|
1039
|
-
var
|
|
1188
|
+
var import_utils15 = require("@typescript-eslint/utils");
|
|
1189
|
+
var createRule12 = import_utils15.ESLintUtils.RuleCreator(
|
|
1040
1190
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1041
1191
|
);
|
|
1042
1192
|
var isIndexFile = (filename) => getBaseName(filename) === "index";
|
|
@@ -1044,26 +1194,26 @@ var isAllowedExportNamed = (node) => {
|
|
|
1044
1194
|
if (!node.declaration) {
|
|
1045
1195
|
return true;
|
|
1046
1196
|
}
|
|
1047
|
-
return node.declaration.type ===
|
|
1197
|
+
return node.declaration.type === import_utils15.AST_NODE_TYPES.TSTypeAliasDeclaration || node.declaration.type === import_utils15.AST_NODE_TYPES.TSInterfaceDeclaration;
|
|
1048
1198
|
};
|
|
1049
|
-
var isAllowedExportDefault = (node) => node.declaration.type ===
|
|
1199
|
+
var isAllowedExportDefault = (node) => node.declaration.type === import_utils15.AST_NODE_TYPES.Identifier;
|
|
1050
1200
|
var isAllowedTopLevel = (node) => {
|
|
1051
1201
|
switch (node.type) {
|
|
1052
|
-
case
|
|
1053
|
-
case
|
|
1054
|
-
case
|
|
1055
|
-
case
|
|
1056
|
-
case
|
|
1202
|
+
case import_utils15.AST_NODE_TYPES.ImportDeclaration:
|
|
1203
|
+
case import_utils15.AST_NODE_TYPES.ExportAllDeclaration:
|
|
1204
|
+
case import_utils15.AST_NODE_TYPES.TSTypeAliasDeclaration:
|
|
1205
|
+
case import_utils15.AST_NODE_TYPES.TSInterfaceDeclaration:
|
|
1206
|
+
case import_utils15.AST_NODE_TYPES.TSImportEqualsDeclaration:
|
|
1057
1207
|
return true;
|
|
1058
|
-
case
|
|
1208
|
+
case import_utils15.AST_NODE_TYPES.ExportNamedDeclaration:
|
|
1059
1209
|
return isAllowedExportNamed(node);
|
|
1060
|
-
case
|
|
1210
|
+
case import_utils15.AST_NODE_TYPES.ExportDefaultDeclaration:
|
|
1061
1211
|
return isAllowedExportDefault(node);
|
|
1062
1212
|
default:
|
|
1063
1213
|
return false;
|
|
1064
1214
|
}
|
|
1065
1215
|
};
|
|
1066
|
-
var indexExportOnly =
|
|
1216
|
+
var indexExportOnly = createRule12({
|
|
1067
1217
|
name: "index-export-only",
|
|
1068
1218
|
meta: {
|
|
1069
1219
|
type: "suggestion",
|
|
@@ -1097,11 +1247,11 @@ var indexExportOnly = createRule11({
|
|
|
1097
1247
|
var index_export_only_default = indexExportOnly;
|
|
1098
1248
|
|
|
1099
1249
|
// src/rules/jsx-newline-between-elements.ts
|
|
1100
|
-
var
|
|
1101
|
-
var
|
|
1250
|
+
var import_utils17 = require("@typescript-eslint/utils");
|
|
1251
|
+
var createRule13 = import_utils17.ESLintUtils.RuleCreator(
|
|
1102
1252
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1103
1253
|
);
|
|
1104
|
-
var jsxNewlineBetweenElements =
|
|
1254
|
+
var jsxNewlineBetweenElements = createRule13({
|
|
1105
1255
|
name: "jsx-newline-between-elements",
|
|
1106
1256
|
meta: {
|
|
1107
1257
|
type: "layout",
|
|
@@ -1119,7 +1269,7 @@ var jsxNewlineBetweenElements = createRule12({
|
|
|
1119
1269
|
create(context) {
|
|
1120
1270
|
const { sourceCode } = context;
|
|
1121
1271
|
function isSignificantJSXChild(node) {
|
|
1122
|
-
return node.type ===
|
|
1272
|
+
return node.type === import_utils17.AST_NODE_TYPES.JSXElement || node.type === import_utils17.AST_NODE_TYPES.JSXFragment || node.type === import_utils17.AST_NODE_TYPES.JSXExpressionContainer;
|
|
1123
1273
|
}
|
|
1124
1274
|
function isMultiLine(node) {
|
|
1125
1275
|
return node.loc.start.line !== node.loc.end.line;
|
|
@@ -1168,12 +1318,194 @@ var jsxNewlineBetweenElements = createRule12({
|
|
|
1168
1318
|
});
|
|
1169
1319
|
var jsx_newline_between_elements_default = jsxNewlineBetweenElements;
|
|
1170
1320
|
|
|
1321
|
+
// src/rules/jsx-no-data-array.ts
|
|
1322
|
+
var import_utils18 = require("@typescript-eslint/utils");
|
|
1323
|
+
var createRule14 = import_utils18.ESLintUtils.RuleCreator(
|
|
1324
|
+
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1325
|
+
);
|
|
1326
|
+
function isObjectLikeElement(node) {
|
|
1327
|
+
if (!node) {
|
|
1328
|
+
return false;
|
|
1329
|
+
}
|
|
1330
|
+
if (node.type === import_utils18.AST_NODE_TYPES.ObjectExpression) {
|
|
1331
|
+
return true;
|
|
1332
|
+
}
|
|
1333
|
+
if (node.type === import_utils18.AST_NODE_TYPES.TSAsExpression || node.type === import_utils18.AST_NODE_TYPES.TSSatisfiesExpression) {
|
|
1334
|
+
return isObjectLikeElement(node.expression);
|
|
1335
|
+
}
|
|
1336
|
+
return false;
|
|
1337
|
+
}
|
|
1338
|
+
function getArrayInitializer(init) {
|
|
1339
|
+
if (!init) {
|
|
1340
|
+
return null;
|
|
1341
|
+
}
|
|
1342
|
+
if (init.type === import_utils18.AST_NODE_TYPES.ArrayExpression) {
|
|
1343
|
+
return init;
|
|
1344
|
+
}
|
|
1345
|
+
if (init.type === import_utils18.AST_NODE_TYPES.TSAsExpression || init.type === import_utils18.AST_NODE_TYPES.TSSatisfiesExpression) {
|
|
1346
|
+
return getArrayInitializer(init.expression);
|
|
1347
|
+
}
|
|
1348
|
+
return null;
|
|
1349
|
+
}
|
|
1350
|
+
var jsxNoDataArray = createRule14({
|
|
1351
|
+
name: "jsx-no-data-array",
|
|
1352
|
+
meta: {
|
|
1353
|
+
type: "problem",
|
|
1354
|
+
docs: {
|
|
1355
|
+
description: "Disallow top-level arrays of object literals in .tsx/.jsx files (extract to a data file)"
|
|
1356
|
+
},
|
|
1357
|
+
schema: [],
|
|
1358
|
+
messages: {
|
|
1359
|
+
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."
|
|
1360
|
+
}
|
|
1361
|
+
},
|
|
1362
|
+
defaultOptions: [],
|
|
1363
|
+
create(context) {
|
|
1364
|
+
const { filename } = context;
|
|
1365
|
+
const extension = getFileExtension(filename);
|
|
1366
|
+
if (extension !== "tsx" && extension !== "jsx") {
|
|
1367
|
+
return {};
|
|
1368
|
+
}
|
|
1369
|
+
return {
|
|
1370
|
+
"Program > VariableDeclaration > VariableDeclarator": function checkDeclarator(node) {
|
|
1371
|
+
const arrayInit = getArrayInitializer(node.init);
|
|
1372
|
+
if (!arrayInit) {
|
|
1373
|
+
return;
|
|
1374
|
+
}
|
|
1375
|
+
const hasObjectElement = arrayInit.elements.some((element) => isObjectLikeElement(element));
|
|
1376
|
+
if (!hasObjectElement) {
|
|
1377
|
+
return;
|
|
1378
|
+
}
|
|
1379
|
+
const name = node.id.type === import_utils18.AST_NODE_TYPES.Identifier ? node.id.name : "<destructured>";
|
|
1380
|
+
context.report({
|
|
1381
|
+
node,
|
|
1382
|
+
messageId: "noDataArray",
|
|
1383
|
+
data: { name }
|
|
1384
|
+
});
|
|
1385
|
+
},
|
|
1386
|
+
"Program > ExportNamedDeclaration > VariableDeclaration > VariableDeclarator": function checkExportedDeclarator(node) {
|
|
1387
|
+
const arrayInit = getArrayInitializer(node.init);
|
|
1388
|
+
if (!arrayInit) {
|
|
1389
|
+
return;
|
|
1390
|
+
}
|
|
1391
|
+
const hasObjectElement = arrayInit.elements.some((element) => isObjectLikeElement(element));
|
|
1392
|
+
if (!hasObjectElement) {
|
|
1393
|
+
return;
|
|
1394
|
+
}
|
|
1395
|
+
const name = node.id.type === import_utils18.AST_NODE_TYPES.Identifier ? node.id.name : "<destructured>";
|
|
1396
|
+
context.report({
|
|
1397
|
+
node,
|
|
1398
|
+
messageId: "noDataArray",
|
|
1399
|
+
data: { name }
|
|
1400
|
+
});
|
|
1401
|
+
}
|
|
1402
|
+
};
|
|
1403
|
+
}
|
|
1404
|
+
});
|
|
1405
|
+
var jsx_no_data_array_default = jsxNoDataArray;
|
|
1406
|
+
|
|
1407
|
+
// src/rules/jsx-no-data-object.ts
|
|
1408
|
+
var import_utils20 = require("@typescript-eslint/utils");
|
|
1409
|
+
var createRule15 = import_utils20.ESLintUtils.RuleCreator(
|
|
1410
|
+
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1411
|
+
);
|
|
1412
|
+
function unwrapAssertion(node) {
|
|
1413
|
+
if (!node) {
|
|
1414
|
+
return null;
|
|
1415
|
+
}
|
|
1416
|
+
if (node.type === import_utils20.AST_NODE_TYPES.TSAsExpression || node.type === import_utils20.AST_NODE_TYPES.TSSatisfiesExpression) {
|
|
1417
|
+
return unwrapAssertion(node.expression);
|
|
1418
|
+
}
|
|
1419
|
+
return node;
|
|
1420
|
+
}
|
|
1421
|
+
function isNestedValue(value) {
|
|
1422
|
+
const unwrapped = unwrapAssertion(value);
|
|
1423
|
+
if (!unwrapped) {
|
|
1424
|
+
return false;
|
|
1425
|
+
}
|
|
1426
|
+
if (unwrapped.type === import_utils20.AST_NODE_TYPES.ObjectExpression) {
|
|
1427
|
+
return true;
|
|
1428
|
+
}
|
|
1429
|
+
if (unwrapped.type === import_utils20.AST_NODE_TYPES.ArrayExpression) {
|
|
1430
|
+
return unwrapped.elements.some((element) => {
|
|
1431
|
+
if (!element || element.type === import_utils20.AST_NODE_TYPES.SpreadElement) {
|
|
1432
|
+
return false;
|
|
1433
|
+
}
|
|
1434
|
+
const inner = unwrapAssertion(element);
|
|
1435
|
+
return inner?.type === import_utils20.AST_NODE_TYPES.ObjectExpression || inner?.type === import_utils20.AST_NODE_TYPES.ArrayExpression;
|
|
1436
|
+
});
|
|
1437
|
+
}
|
|
1438
|
+
return false;
|
|
1439
|
+
}
|
|
1440
|
+
function hasNestedProperty(object) {
|
|
1441
|
+
return object.properties.some((property) => {
|
|
1442
|
+
if (property.type !== import_utils20.AST_NODE_TYPES.Property) {
|
|
1443
|
+
return false;
|
|
1444
|
+
}
|
|
1445
|
+
if (property.value.type === import_utils20.AST_NODE_TYPES.AssignmentPattern) {
|
|
1446
|
+
return false;
|
|
1447
|
+
}
|
|
1448
|
+
return isNestedValue(property.value);
|
|
1449
|
+
});
|
|
1450
|
+
}
|
|
1451
|
+
function getObjectInitializer(init) {
|
|
1452
|
+
const unwrapped = unwrapAssertion(init);
|
|
1453
|
+
if (!unwrapped) {
|
|
1454
|
+
return null;
|
|
1455
|
+
}
|
|
1456
|
+
if (unwrapped.type === import_utils20.AST_NODE_TYPES.ObjectExpression) {
|
|
1457
|
+
return unwrapped;
|
|
1458
|
+
}
|
|
1459
|
+
return null;
|
|
1460
|
+
}
|
|
1461
|
+
var jsxNoDataObject = createRule15({
|
|
1462
|
+
name: "jsx-no-data-object",
|
|
1463
|
+
meta: {
|
|
1464
|
+
type: "problem",
|
|
1465
|
+
docs: {
|
|
1466
|
+
description: "Disallow top-level nested object literals in .tsx/.jsx files (extract to a data file)"
|
|
1467
|
+
},
|
|
1468
|
+
schema: [],
|
|
1469
|
+
messages: {
|
|
1470
|
+
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."
|
|
1471
|
+
}
|
|
1472
|
+
},
|
|
1473
|
+
defaultOptions: [],
|
|
1474
|
+
create(context) {
|
|
1475
|
+
const { filename } = context;
|
|
1476
|
+
const extension = getFileExtension(filename);
|
|
1477
|
+
if (extension !== "tsx" && extension !== "jsx") {
|
|
1478
|
+
return {};
|
|
1479
|
+
}
|
|
1480
|
+
function checkDeclarator(node) {
|
|
1481
|
+
const objectInit = getObjectInitializer(node.init);
|
|
1482
|
+
if (!objectInit) {
|
|
1483
|
+
return;
|
|
1484
|
+
}
|
|
1485
|
+
if (!hasNestedProperty(objectInit)) {
|
|
1486
|
+
return;
|
|
1487
|
+
}
|
|
1488
|
+
const name = node.id.type === import_utils20.AST_NODE_TYPES.Identifier ? node.id.name : "<destructured>";
|
|
1489
|
+
context.report({
|
|
1490
|
+
node,
|
|
1491
|
+
messageId: "noDataObject",
|
|
1492
|
+
data: { name }
|
|
1493
|
+
});
|
|
1494
|
+
}
|
|
1495
|
+
return {
|
|
1496
|
+
"Program > VariableDeclaration > VariableDeclarator": checkDeclarator,
|
|
1497
|
+
"Program > ExportNamedDeclaration > VariableDeclaration > VariableDeclarator": checkDeclarator
|
|
1498
|
+
};
|
|
1499
|
+
}
|
|
1500
|
+
});
|
|
1501
|
+
var jsx_no_data_object_default = jsxNoDataObject;
|
|
1502
|
+
|
|
1171
1503
|
// src/rules/jsx-no-inline-object-prop.ts
|
|
1172
|
-
var
|
|
1173
|
-
var
|
|
1504
|
+
var import_utils22 = require("@typescript-eslint/utils");
|
|
1505
|
+
var createRule16 = import_utils22.ESLintUtils.RuleCreator(
|
|
1174
1506
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1175
1507
|
);
|
|
1176
|
-
var jsxNoInlineObjectProp =
|
|
1508
|
+
var jsxNoInlineObjectProp = createRule16({
|
|
1177
1509
|
name: "jsx-no-inline-object-prop",
|
|
1178
1510
|
meta: {
|
|
1179
1511
|
type: "suggestion",
|
|
@@ -1189,7 +1521,7 @@ var jsxNoInlineObjectProp = createRule13({
|
|
|
1189
1521
|
create(context) {
|
|
1190
1522
|
return {
|
|
1191
1523
|
JSXAttribute(node) {
|
|
1192
|
-
if (node.value?.type ===
|
|
1524
|
+
if (node.value?.type === import_utils22.AST_NODE_TYPES.JSXExpressionContainer && node.value.expression.type === import_utils22.AST_NODE_TYPES.ObjectExpression) {
|
|
1193
1525
|
context.report({
|
|
1194
1526
|
node: node.value,
|
|
1195
1527
|
messageId: "noInlineObject"
|
|
@@ -1202,17 +1534,17 @@ var jsxNoInlineObjectProp = createRule13({
|
|
|
1202
1534
|
var jsx_no_inline_object_prop_default = jsxNoInlineObjectProp;
|
|
1203
1535
|
|
|
1204
1536
|
// src/rules/jsx-no-newline-single-line-elements.ts
|
|
1205
|
-
var
|
|
1206
|
-
var
|
|
1537
|
+
var import_utils23 = require("@typescript-eslint/utils");
|
|
1538
|
+
var createRule17 = import_utils23.ESLintUtils.RuleCreator(
|
|
1207
1539
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1208
1540
|
);
|
|
1209
1541
|
function isJSXElementOrFragment(node) {
|
|
1210
|
-
return node.type ===
|
|
1542
|
+
return node.type === import_utils23.AST_NODE_TYPES.JSXElement || node.type === import_utils23.AST_NODE_TYPES.JSXFragment;
|
|
1211
1543
|
}
|
|
1212
1544
|
function isSingleLine(node) {
|
|
1213
1545
|
return node.loc.start.line === node.loc.end.line;
|
|
1214
1546
|
}
|
|
1215
|
-
var jsxNoNewlineSingleLineElements =
|
|
1547
|
+
var jsxNoNewlineSingleLineElements = createRule17({
|
|
1216
1548
|
name: "jsx-no-newline-single-line-elements",
|
|
1217
1549
|
meta: {
|
|
1218
1550
|
type: "layout",
|
|
@@ -1230,7 +1562,7 @@ var jsxNoNewlineSingleLineElements = createRule14({
|
|
|
1230
1562
|
const { sourceCode } = context;
|
|
1231
1563
|
function checkSiblings(children) {
|
|
1232
1564
|
const nonWhitespace = children.filter(
|
|
1233
|
-
(child) => !(child.type ===
|
|
1565
|
+
(child) => !(child.type === import_utils23.AST_NODE_TYPES.JSXText && child.value.trim() === "")
|
|
1234
1566
|
);
|
|
1235
1567
|
nonWhitespace.forEach((next, index) => {
|
|
1236
1568
|
if (index === 0) {
|
|
@@ -1281,11 +1613,11 @@ ${indent}`);
|
|
|
1281
1613
|
var jsx_no_newline_single_line_elements_default = jsxNoNewlineSingleLineElements;
|
|
1282
1614
|
|
|
1283
1615
|
// src/rules/jsx-no-non-component-function.ts
|
|
1284
|
-
var
|
|
1285
|
-
var
|
|
1616
|
+
var import_utils24 = require("@typescript-eslint/utils");
|
|
1617
|
+
var createRule18 = import_utils24.ESLintUtils.RuleCreator(
|
|
1286
1618
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1287
1619
|
);
|
|
1288
|
-
var jsxNoNonComponentFunction =
|
|
1620
|
+
var jsxNoNonComponentFunction = createRule18({
|
|
1289
1621
|
name: "jsx-no-non-component-function",
|
|
1290
1622
|
meta: {
|
|
1291
1623
|
type: "problem",
|
|
@@ -1305,13 +1637,13 @@ var jsxNoNonComponentFunction = createRule15({
|
|
|
1305
1637
|
return {};
|
|
1306
1638
|
}
|
|
1307
1639
|
function isReactComponent2(node) {
|
|
1308
|
-
const functionName = node.type ===
|
|
1640
|
+
const functionName = node.type === import_utils24.AST_NODE_TYPES.FunctionDeclaration && node.id ? node.id.name : null;
|
|
1309
1641
|
if (functionName && /^[A-Z]/.test(functionName)) {
|
|
1310
1642
|
return true;
|
|
1311
1643
|
}
|
|
1312
1644
|
if (node.returnType?.typeAnnotation) {
|
|
1313
1645
|
const returnTypeNode = node.returnType.typeAnnotation;
|
|
1314
|
-
if (returnTypeNode.type ===
|
|
1646
|
+
if (returnTypeNode.type === import_utils24.AST_NODE_TYPES.TSTypeReference && returnTypeNode.typeName.type === import_utils24.AST_NODE_TYPES.Identifier) {
|
|
1315
1647
|
const typeName = returnTypeNode.typeName.name;
|
|
1316
1648
|
if (typeName === "JSX" || typeName === "ReactElement" || typeName === "ReactNode") {
|
|
1317
1649
|
return true;
|
|
@@ -1328,13 +1660,13 @@ var jsxNoNonComponentFunction = createRule15({
|
|
|
1328
1660
|
if (!parent) {
|
|
1329
1661
|
return;
|
|
1330
1662
|
}
|
|
1331
|
-
if (parent.type ===
|
|
1663
|
+
if (parent.type === import_utils24.AST_NODE_TYPES.ExportDefaultDeclaration || parent.type === import_utils24.AST_NODE_TYPES.ExportNamedDeclaration) {
|
|
1332
1664
|
return;
|
|
1333
1665
|
}
|
|
1334
|
-
if (declaratorNode?.parent?.parent?.type ===
|
|
1666
|
+
if (declaratorNode?.parent?.parent?.type === import_utils24.AST_NODE_TYPES.ExportNamedDeclaration) {
|
|
1335
1667
|
return;
|
|
1336
1668
|
}
|
|
1337
|
-
if (declaratorNode?.id.type ===
|
|
1669
|
+
if (declaratorNode?.id.type === import_utils24.AST_NODE_TYPES.Identifier) {
|
|
1338
1670
|
const varName = declaratorNode.id.name;
|
|
1339
1671
|
if (/^[A-Z]/.test(varName)) {
|
|
1340
1672
|
return;
|
|
@@ -1358,21 +1690,146 @@ var jsxNoNonComponentFunction = createRule15({
|
|
|
1358
1690
|
});
|
|
1359
1691
|
var jsx_no_non_component_function_default = jsxNoNonComponentFunction;
|
|
1360
1692
|
|
|
1693
|
+
// src/rules/jsx-no-sub-interface.ts
|
|
1694
|
+
var import_utils26 = require("@typescript-eslint/utils");
|
|
1695
|
+
var createRule19 = import_utils26.ESLintUtils.RuleCreator(
|
|
1696
|
+
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1697
|
+
);
|
|
1698
|
+
var PROPS_WRAPPER_NAMES = /* @__PURE__ */ new Set(["Readonly", "Required", "Partial", "PropsWithChildren", "NoInfer"]);
|
|
1699
|
+
function unwrapWrapperType(node) {
|
|
1700
|
+
if (node.type === import_utils26.AST_NODE_TYPES.TSTypeReference && node.typeName.type === import_utils26.AST_NODE_TYPES.Identifier && PROPS_WRAPPER_NAMES.has(node.typeName.name) && node.typeArguments && node.typeArguments.params.length > 0) {
|
|
1701
|
+
return unwrapWrapperType(node.typeArguments.params[0]);
|
|
1702
|
+
}
|
|
1703
|
+
return node;
|
|
1704
|
+
}
|
|
1705
|
+
function getMainTypeName(typeNode) {
|
|
1706
|
+
if (!typeNode) {
|
|
1707
|
+
return null;
|
|
1708
|
+
}
|
|
1709
|
+
const unwrapped = unwrapWrapperType(typeNode);
|
|
1710
|
+
if (unwrapped.type === import_utils26.AST_NODE_TYPES.TSTypeReference && unwrapped.typeName.type === import_utils26.AST_NODE_TYPES.Identifier) {
|
|
1711
|
+
return unwrapped.typeName.name;
|
|
1712
|
+
}
|
|
1713
|
+
return null;
|
|
1714
|
+
}
|
|
1715
|
+
function getComponentMainTypeName(node) {
|
|
1716
|
+
const firstParam = node.params[0];
|
|
1717
|
+
if (!firstParam) {
|
|
1718
|
+
return null;
|
|
1719
|
+
}
|
|
1720
|
+
if ("typeAnnotation" in firstParam && firstParam.typeAnnotation) {
|
|
1721
|
+
return getMainTypeName(firstParam.typeAnnotation.typeAnnotation);
|
|
1722
|
+
}
|
|
1723
|
+
return null;
|
|
1724
|
+
}
|
|
1725
|
+
function isPascalCase2(name) {
|
|
1726
|
+
return /^[A-Z]/.test(name);
|
|
1727
|
+
}
|
|
1728
|
+
function getDeclarationFromExportWrapper(node) {
|
|
1729
|
+
if (node.type === import_utils26.AST_NODE_TYPES.ExportNamedDeclaration && node.declaration) {
|
|
1730
|
+
return node.declaration;
|
|
1731
|
+
}
|
|
1732
|
+
if (node.type === import_utils26.AST_NODE_TYPES.ExportDefaultDeclaration) {
|
|
1733
|
+
return node.declaration;
|
|
1734
|
+
}
|
|
1735
|
+
return node;
|
|
1736
|
+
}
|
|
1737
|
+
var jsxNoSubInterface = createRule19({
|
|
1738
|
+
name: "jsx-no-sub-interface",
|
|
1739
|
+
meta: {
|
|
1740
|
+
type: "problem",
|
|
1741
|
+
docs: {
|
|
1742
|
+
description: "Disallow sub-interfaces and helper types in component files; keep only the main component props (extract the rest)"
|
|
1743
|
+
},
|
|
1744
|
+
schema: [],
|
|
1745
|
+
messages: {
|
|
1746
|
+
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)."
|
|
1747
|
+
}
|
|
1748
|
+
},
|
|
1749
|
+
defaultOptions: [],
|
|
1750
|
+
create(context) {
|
|
1751
|
+
const { filename } = context;
|
|
1752
|
+
const extension = getFileExtension(filename);
|
|
1753
|
+
if (extension !== "tsx" && extension !== "jsx") {
|
|
1754
|
+
return {};
|
|
1755
|
+
}
|
|
1756
|
+
return {
|
|
1757
|
+
Program(programNode) {
|
|
1758
|
+
const mainTypes = /* @__PURE__ */ new Set();
|
|
1759
|
+
const typeDeclarations = [];
|
|
1760
|
+
let componentCount = 0;
|
|
1761
|
+
for (const statement of programNode.body) {
|
|
1762
|
+
const declaration = getDeclarationFromExportWrapper(statement);
|
|
1763
|
+
if (declaration.type === import_utils26.AST_NODE_TYPES.FunctionDeclaration && declaration.id && isPascalCase2(declaration.id.name)) {
|
|
1764
|
+
componentCount += 1;
|
|
1765
|
+
const mainType = getComponentMainTypeName(declaration);
|
|
1766
|
+
if (mainType) {
|
|
1767
|
+
mainTypes.add(mainType);
|
|
1768
|
+
}
|
|
1769
|
+
continue;
|
|
1770
|
+
}
|
|
1771
|
+
if (declaration.type === import_utils26.AST_NODE_TYPES.VariableDeclaration) {
|
|
1772
|
+
for (const declarator of declaration.declarations) {
|
|
1773
|
+
if (declarator.id.type !== import_utils26.AST_NODE_TYPES.Identifier) {
|
|
1774
|
+
continue;
|
|
1775
|
+
}
|
|
1776
|
+
if (!isPascalCase2(declarator.id.name)) {
|
|
1777
|
+
continue;
|
|
1778
|
+
}
|
|
1779
|
+
const init = declarator.init;
|
|
1780
|
+
if (init && (init.type === import_utils26.AST_NODE_TYPES.ArrowFunctionExpression || init.type === import_utils26.AST_NODE_TYPES.FunctionExpression)) {
|
|
1781
|
+
componentCount += 1;
|
|
1782
|
+
const mainType = getComponentMainTypeName(init);
|
|
1783
|
+
if (mainType) {
|
|
1784
|
+
mainTypes.add(mainType);
|
|
1785
|
+
}
|
|
1786
|
+
}
|
|
1787
|
+
}
|
|
1788
|
+
continue;
|
|
1789
|
+
}
|
|
1790
|
+
if (declaration.type === import_utils26.AST_NODE_TYPES.TSInterfaceDeclaration) {
|
|
1791
|
+
typeDeclarations.push({ name: declaration.id.name, node: declaration });
|
|
1792
|
+
continue;
|
|
1793
|
+
}
|
|
1794
|
+
if (declaration.type === import_utils26.AST_NODE_TYPES.TSTypeAliasDeclaration) {
|
|
1795
|
+
typeDeclarations.push({ name: declaration.id.name, node: declaration });
|
|
1796
|
+
continue;
|
|
1797
|
+
}
|
|
1798
|
+
}
|
|
1799
|
+
if (componentCount === 0) {
|
|
1800
|
+
return;
|
|
1801
|
+
}
|
|
1802
|
+
for (const declaration of typeDeclarations) {
|
|
1803
|
+
if (mainTypes.has(declaration.name)) {
|
|
1804
|
+
continue;
|
|
1805
|
+
}
|
|
1806
|
+
context.report({
|
|
1807
|
+
node: declaration.node,
|
|
1808
|
+
messageId: "noSubInterface",
|
|
1809
|
+
data: { name: declaration.name }
|
|
1810
|
+
});
|
|
1811
|
+
}
|
|
1812
|
+
}
|
|
1813
|
+
};
|
|
1814
|
+
}
|
|
1815
|
+
});
|
|
1816
|
+
var jsx_no_sub_interface_default = jsxNoSubInterface;
|
|
1817
|
+
|
|
1361
1818
|
// src/rules/jsx-no-ternary-null.ts
|
|
1362
|
-
var
|
|
1363
|
-
var
|
|
1819
|
+
var import_utils28 = require("@typescript-eslint/utils");
|
|
1820
|
+
var createRule20 = import_utils28.ESLintUtils.RuleCreator(
|
|
1364
1821
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1365
1822
|
);
|
|
1366
1823
|
function isNullOrUndefined(node) {
|
|
1367
|
-
if (node.type ===
|
|
1824
|
+
if (node.type === import_utils28.AST_NODE_TYPES.Literal && node.value === null) {
|
|
1368
1825
|
return true;
|
|
1369
1826
|
}
|
|
1370
|
-
if (node.type ===
|
|
1827
|
+
if (node.type === import_utils28.AST_NODE_TYPES.Identifier && node.name === "undefined") {
|
|
1371
1828
|
return true;
|
|
1372
1829
|
}
|
|
1373
1830
|
return false;
|
|
1374
1831
|
}
|
|
1375
|
-
var jsxNoTernaryNull =
|
|
1832
|
+
var jsxNoTernaryNull = createRule20({
|
|
1376
1833
|
name: "jsx-no-ternary-null",
|
|
1377
1834
|
meta: {
|
|
1378
1835
|
type: "suggestion",
|
|
@@ -1390,7 +1847,7 @@ var jsxNoTernaryNull = createRule16({
|
|
|
1390
1847
|
return {
|
|
1391
1848
|
JSXExpressionContainer(node) {
|
|
1392
1849
|
const { expression } = node;
|
|
1393
|
-
if (expression.type !==
|
|
1850
|
+
if (expression.type !== import_utils28.AST_NODE_TYPES.ConditionalExpression) {
|
|
1394
1851
|
return;
|
|
1395
1852
|
}
|
|
1396
1853
|
const { test, consequent, alternate } = expression;
|
|
@@ -1422,11 +1879,11 @@ var jsxNoTernaryNull = createRule16({
|
|
|
1422
1879
|
var jsx_no_ternary_null_default = jsxNoTernaryNull;
|
|
1423
1880
|
|
|
1424
1881
|
// src/rules/jsx-no-variable-in-callback.ts
|
|
1425
|
-
var
|
|
1426
|
-
var
|
|
1882
|
+
var import_utils29 = require("@typescript-eslint/utils");
|
|
1883
|
+
var createRule21 = import_utils29.ESLintUtils.RuleCreator(
|
|
1427
1884
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1428
1885
|
);
|
|
1429
|
-
var jsxNoVariableInCallback =
|
|
1886
|
+
var jsxNoVariableInCallback = createRule21({
|
|
1430
1887
|
name: "jsx-no-variable-in-callback",
|
|
1431
1888
|
meta: {
|
|
1432
1889
|
type: "suggestion",
|
|
@@ -1443,7 +1900,7 @@ var jsxNoVariableInCallback = createRule17({
|
|
|
1443
1900
|
function isInsideJSX(node) {
|
|
1444
1901
|
let current = node.parent;
|
|
1445
1902
|
while (current) {
|
|
1446
|
-
if (current.type ===
|
|
1903
|
+
if (current.type === import_utils29.AST_NODE_TYPES.JSXElement || current.type === import_utils29.AST_NODE_TYPES.JSXFragment) {
|
|
1447
1904
|
return true;
|
|
1448
1905
|
}
|
|
1449
1906
|
current = current.parent;
|
|
@@ -1457,11 +1914,11 @@ var jsxNoVariableInCallback = createRule17({
|
|
|
1457
1914
|
if (!isInsideJSX(node)) {
|
|
1458
1915
|
return false;
|
|
1459
1916
|
}
|
|
1460
|
-
if (node.parent.type ===
|
|
1917
|
+
if (node.parent.type === import_utils29.AST_NODE_TYPES.CallExpression || node.parent.type === import_utils29.AST_NODE_TYPES.JSXExpressionContainer) {
|
|
1461
1918
|
return true;
|
|
1462
1919
|
}
|
|
1463
|
-
if (node.parent.type ===
|
|
1464
|
-
if (node.parent.parent.type ===
|
|
1920
|
+
if (node.parent.type === import_utils29.AST_NODE_TYPES.ArrayExpression && node.parent.parent) {
|
|
1921
|
+
if (node.parent.parent.type === import_utils29.AST_NODE_TYPES.CallExpression || node.parent.parent.type === import_utils29.AST_NODE_TYPES.JSXExpressionContainer) {
|
|
1465
1922
|
return true;
|
|
1466
1923
|
}
|
|
1467
1924
|
}
|
|
@@ -1472,11 +1929,11 @@ var jsxNoVariableInCallback = createRule17({
|
|
|
1472
1929
|
return;
|
|
1473
1930
|
}
|
|
1474
1931
|
const { body } = node;
|
|
1475
|
-
if (body.type !==
|
|
1932
|
+
if (body.type !== import_utils29.AST_NODE_TYPES.BlockStatement) {
|
|
1476
1933
|
return;
|
|
1477
1934
|
}
|
|
1478
1935
|
body.body.forEach((statement) => {
|
|
1479
|
-
if (statement.type ===
|
|
1936
|
+
if (statement.type === import_utils29.AST_NODE_TYPES.VariableDeclaration) {
|
|
1480
1937
|
context.report({
|
|
1481
1938
|
node: statement,
|
|
1482
1939
|
messageId: "noVariableInCallback"
|
|
@@ -1493,11 +1950,11 @@ var jsxNoVariableInCallback = createRule17({
|
|
|
1493
1950
|
var jsx_no_variable_in_callback_default = jsxNoVariableInCallback;
|
|
1494
1951
|
|
|
1495
1952
|
// src/rules/jsx-require-suspense.ts
|
|
1496
|
-
var
|
|
1497
|
-
var
|
|
1953
|
+
var import_utils30 = require("@typescript-eslint/utils");
|
|
1954
|
+
var createRule22 = import_utils30.ESLintUtils.RuleCreator(
|
|
1498
1955
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1499
1956
|
);
|
|
1500
|
-
var jsxRequireSuspense =
|
|
1957
|
+
var jsxRequireSuspense = createRule22({
|
|
1501
1958
|
name: "jsx-require-suspense",
|
|
1502
1959
|
meta: {
|
|
1503
1960
|
type: "problem",
|
|
@@ -1515,7 +1972,7 @@ var jsxRequireSuspense = createRule18({
|
|
|
1515
1972
|
const isInsideSuspense = (node) => {
|
|
1516
1973
|
let current = node.parent;
|
|
1517
1974
|
while (current) {
|
|
1518
|
-
if (current.type ===
|
|
1975
|
+
if (current.type === import_utils30.AST_NODE_TYPES.JSXElement && current.openingElement.name.type === import_utils30.AST_NODE_TYPES.JSXIdentifier && current.openingElement.name.name === "Suspense") {
|
|
1519
1976
|
return true;
|
|
1520
1977
|
}
|
|
1521
1978
|
current = current.parent;
|
|
@@ -1524,16 +1981,16 @@ var jsxRequireSuspense = createRule18({
|
|
|
1524
1981
|
};
|
|
1525
1982
|
return {
|
|
1526
1983
|
VariableDeclarator(node) {
|
|
1527
|
-
if (node.id.type ===
|
|
1984
|
+
if (node.id.type === import_utils30.AST_NODE_TYPES.Identifier && node.init?.type === import_utils30.AST_NODE_TYPES.CallExpression) {
|
|
1528
1985
|
const { callee } = node.init;
|
|
1529
|
-
const isLazyCall = callee.type ===
|
|
1986
|
+
const isLazyCall = callee.type === import_utils30.AST_NODE_TYPES.Identifier && callee.name === "lazy" || callee.type === import_utils30.AST_NODE_TYPES.MemberExpression && callee.object.type === import_utils30.AST_NODE_TYPES.Identifier && callee.object.name === "React" && callee.property.type === import_utils30.AST_NODE_TYPES.Identifier && callee.property.name === "lazy";
|
|
1530
1987
|
if (isLazyCall) {
|
|
1531
1988
|
lazyComponents.add(node.id.name);
|
|
1532
1989
|
}
|
|
1533
1990
|
}
|
|
1534
1991
|
},
|
|
1535
1992
|
JSXOpeningElement(node) {
|
|
1536
|
-
if (node.name.type ===
|
|
1993
|
+
if (node.name.type === import_utils30.AST_NODE_TYPES.JSXIdentifier) {
|
|
1537
1994
|
const componentName = node.name.name;
|
|
1538
1995
|
if (lazyComponents.has(componentName) && !isInsideSuspense(node)) {
|
|
1539
1996
|
context.report({
|
|
@@ -1552,11 +2009,11 @@ var jsxRequireSuspense = createRule18({
|
|
|
1552
2009
|
var jsx_require_suspense_default = jsxRequireSuspense;
|
|
1553
2010
|
|
|
1554
2011
|
// src/rules/jsx-simple-props.ts
|
|
1555
|
-
var
|
|
1556
|
-
var
|
|
2012
|
+
var import_utils31 = require("@typescript-eslint/utils");
|
|
2013
|
+
var createRule23 = import_utils31.ESLintUtils.RuleCreator(
|
|
1557
2014
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1558
2015
|
);
|
|
1559
|
-
var jsxSimpleProps =
|
|
2016
|
+
var jsxSimpleProps = createRule23({
|
|
1560
2017
|
name: "jsx-simple-props",
|
|
1561
2018
|
meta: {
|
|
1562
2019
|
type: "suggestion",
|
|
@@ -1571,25 +2028,25 @@ var jsxSimpleProps = createRule19({
|
|
|
1571
2028
|
defaultOptions: [],
|
|
1572
2029
|
create(context) {
|
|
1573
2030
|
const allowedExpressionTypes = /* @__PURE__ */ new Set([
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
2031
|
+
import_utils31.AST_NODE_TYPES.Identifier,
|
|
2032
|
+
import_utils31.AST_NODE_TYPES.Literal,
|
|
2033
|
+
import_utils31.AST_NODE_TYPES.JSXElement,
|
|
2034
|
+
import_utils31.AST_NODE_TYPES.JSXFragment,
|
|
2035
|
+
import_utils31.AST_NODE_TYPES.MemberExpression,
|
|
2036
|
+
import_utils31.AST_NODE_TYPES.ArrowFunctionExpression,
|
|
2037
|
+
import_utils31.AST_NODE_TYPES.FunctionExpression
|
|
1581
2038
|
]);
|
|
1582
2039
|
return {
|
|
1583
2040
|
JSXAttribute(node) {
|
|
1584
2041
|
if (!node.value) {
|
|
1585
2042
|
return;
|
|
1586
2043
|
}
|
|
1587
|
-
if (node.value.type ===
|
|
2044
|
+
if (node.value.type === import_utils31.AST_NODE_TYPES.Literal) {
|
|
1588
2045
|
return;
|
|
1589
2046
|
}
|
|
1590
|
-
if (node.value.type ===
|
|
2047
|
+
if (node.value.type === import_utils31.AST_NODE_TYPES.JSXExpressionContainer) {
|
|
1591
2048
|
const { expression } = node.value;
|
|
1592
|
-
if (expression.type ===
|
|
2049
|
+
if (expression.type === import_utils31.AST_NODE_TYPES.JSXEmptyExpression) {
|
|
1593
2050
|
return;
|
|
1594
2051
|
}
|
|
1595
2052
|
if (!allowedExpressionTypes.has(expression.type)) {
|
|
@@ -1606,8 +2063,8 @@ var jsxSimpleProps = createRule19({
|
|
|
1606
2063
|
var jsx_simple_props_default = jsxSimpleProps;
|
|
1607
2064
|
|
|
1608
2065
|
// src/rules/jsx-sort-props.ts
|
|
1609
|
-
var
|
|
1610
|
-
var
|
|
2066
|
+
var import_utils32 = require("@typescript-eslint/utils");
|
|
2067
|
+
var createRule24 = import_utils32.ESLintUtils.RuleCreator(
|
|
1611
2068
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1612
2069
|
);
|
|
1613
2070
|
var TYPE_GROUP = {
|
|
@@ -1621,15 +2078,15 @@ var TYPE_GROUP = {
|
|
|
1621
2078
|
SHORTHAND: 8
|
|
1622
2079
|
};
|
|
1623
2080
|
var EXPRESSION_TYPE_TO_GROUP = /* @__PURE__ */ new Map([
|
|
1624
|
-
[
|
|
1625
|
-
[
|
|
1626
|
-
[
|
|
1627
|
-
[
|
|
1628
|
-
[
|
|
1629
|
-
[
|
|
2081
|
+
[import_utils32.AST_NODE_TYPES.ObjectExpression, TYPE_GROUP.OBJECT_ARRAY],
|
|
2082
|
+
[import_utils32.AST_NODE_TYPES.ArrayExpression, TYPE_GROUP.OBJECT_ARRAY],
|
|
2083
|
+
[import_utils32.AST_NODE_TYPES.ArrowFunctionExpression, TYPE_GROUP.FUNCTION],
|
|
2084
|
+
[import_utils32.AST_NODE_TYPES.FunctionExpression, TYPE_GROUP.FUNCTION],
|
|
2085
|
+
[import_utils32.AST_NODE_TYPES.JSXElement, TYPE_GROUP.JSX],
|
|
2086
|
+
[import_utils32.AST_NODE_TYPES.JSXFragment, TYPE_GROUP.JSX]
|
|
1630
2087
|
]);
|
|
1631
2088
|
function isHyphenatedName(node) {
|
|
1632
|
-
return node.name.type ===
|
|
2089
|
+
return node.name.type === import_utils32.AST_NODE_TYPES.JSXIdentifier && node.name.name.includes("-");
|
|
1633
2090
|
}
|
|
1634
2091
|
function getStringGroup(node) {
|
|
1635
2092
|
return isHyphenatedName(node) ? TYPE_GROUP.HYPHENATED_STRING : TYPE_GROUP.STRING;
|
|
@@ -1641,13 +2098,13 @@ function getLiteralValueGroup(value) {
|
|
|
1641
2098
|
return TYPE_GROUP.NUMBER_BOOLEAN_NULL;
|
|
1642
2099
|
}
|
|
1643
2100
|
function getExpressionGroup(expression) {
|
|
1644
|
-
if (expression.type ===
|
|
2101
|
+
if (expression.type === import_utils32.AST_NODE_TYPES.Literal) {
|
|
1645
2102
|
return getLiteralValueGroup(expression.value);
|
|
1646
2103
|
}
|
|
1647
|
-
if (expression.type ===
|
|
2104
|
+
if (expression.type === import_utils32.AST_NODE_TYPES.TemplateLiteral) {
|
|
1648
2105
|
return null;
|
|
1649
2106
|
}
|
|
1650
|
-
if (expression.type ===
|
|
2107
|
+
if (expression.type === import_utils32.AST_NODE_TYPES.Identifier && expression.name === "undefined") {
|
|
1651
2108
|
return TYPE_GROUP.NUMBER_BOOLEAN_NULL;
|
|
1652
2109
|
}
|
|
1653
2110
|
return EXPRESSION_TYPE_TO_GROUP.get(expression.type) ?? TYPE_GROUP.EXPRESSION;
|
|
@@ -1656,17 +2113,17 @@ function getTypeGroup(node) {
|
|
|
1656
2113
|
if (node.value === null) {
|
|
1657
2114
|
return TYPE_GROUP.SHORTHAND;
|
|
1658
2115
|
}
|
|
1659
|
-
if (node.value.type ===
|
|
2116
|
+
if (node.value.type === import_utils32.AST_NODE_TYPES.Literal) {
|
|
1660
2117
|
if (typeof node.value.value === "string") {
|
|
1661
2118
|
return getStringGroup(node);
|
|
1662
2119
|
}
|
|
1663
2120
|
return TYPE_GROUP.NUMBER_BOOLEAN_NULL;
|
|
1664
2121
|
}
|
|
1665
|
-
if (node.value.type !==
|
|
2122
|
+
if (node.value.type !== import_utils32.AST_NODE_TYPES.JSXExpressionContainer) {
|
|
1666
2123
|
return null;
|
|
1667
2124
|
}
|
|
1668
2125
|
const { expression } = node.value;
|
|
1669
|
-
if (expression.type ===
|
|
2126
|
+
if (expression.type === import_utils32.AST_NODE_TYPES.JSXEmptyExpression) {
|
|
1670
2127
|
return null;
|
|
1671
2128
|
}
|
|
1672
2129
|
const group = getExpressionGroup(expression);
|
|
@@ -1678,7 +2135,7 @@ function getTypeGroup(node) {
|
|
|
1678
2135
|
function hasUnsortedProps(attributes) {
|
|
1679
2136
|
let lastGroup = 0;
|
|
1680
2137
|
return attributes.some((attribute) => {
|
|
1681
|
-
if (attribute.type ===
|
|
2138
|
+
if (attribute.type === import_utils32.AST_NODE_TYPES.JSXSpreadAttribute) {
|
|
1682
2139
|
lastGroup = 0;
|
|
1683
2140
|
return false;
|
|
1684
2141
|
}
|
|
@@ -1702,7 +2159,7 @@ function getSegments(attributes) {
|
|
|
1702
2159
|
const result = [];
|
|
1703
2160
|
let current = [];
|
|
1704
2161
|
attributes.forEach((attr) => {
|
|
1705
|
-
if (attr.type ===
|
|
2162
|
+
if (attr.type === import_utils32.AST_NODE_TYPES.JSXSpreadAttribute) {
|
|
1706
2163
|
if (current.length > 0) {
|
|
1707
2164
|
result.push(current);
|
|
1708
2165
|
current = [];
|
|
@@ -1716,7 +2173,7 @@ function getSegments(attributes) {
|
|
|
1716
2173
|
}
|
|
1717
2174
|
return result;
|
|
1718
2175
|
}
|
|
1719
|
-
var jsxSortProps =
|
|
2176
|
+
var jsxSortProps = createRule24({
|
|
1720
2177
|
name: "jsx-sort-props",
|
|
1721
2178
|
meta: {
|
|
1722
2179
|
type: "suggestion",
|
|
@@ -1751,11 +2208,11 @@ var jsxSortProps = createRule20({
|
|
|
1751
2208
|
var jsx_sort_props_default = jsxSortProps;
|
|
1752
2209
|
|
|
1753
2210
|
// src/rules/jsx-spread-props-last.ts
|
|
1754
|
-
var
|
|
1755
|
-
var
|
|
2211
|
+
var import_utils33 = require("@typescript-eslint/utils");
|
|
2212
|
+
var createRule25 = import_utils33.ESLintUtils.RuleCreator(
|
|
1756
2213
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1757
2214
|
);
|
|
1758
|
-
var jsxSpreadPropsLast =
|
|
2215
|
+
var jsxSpreadPropsLast = createRule25({
|
|
1759
2216
|
name: "jsx-spread-props-last",
|
|
1760
2217
|
meta: {
|
|
1761
2218
|
type: "suggestion",
|
|
@@ -1774,12 +2231,12 @@ var jsxSpreadPropsLast = createRule21({
|
|
|
1774
2231
|
const { attributes } = node;
|
|
1775
2232
|
let lastNonSpreadIndex = -1;
|
|
1776
2233
|
attributes.forEach((attribute, index) => {
|
|
1777
|
-
if (attribute.type !==
|
|
2234
|
+
if (attribute.type !== import_utils33.AST_NODE_TYPES.JSXSpreadAttribute) {
|
|
1778
2235
|
lastNonSpreadIndex = index;
|
|
1779
2236
|
}
|
|
1780
2237
|
});
|
|
1781
2238
|
attributes.forEach((attribute, index) => {
|
|
1782
|
-
if (attribute.type ===
|
|
2239
|
+
if (attribute.type === import_utils33.AST_NODE_TYPES.JSXSpreadAttribute && index < lastNonSpreadIndex) {
|
|
1783
2240
|
context.report({
|
|
1784
2241
|
node: attribute,
|
|
1785
2242
|
messageId: "spreadNotLast"
|
|
@@ -1793,12 +2250,12 @@ var jsxSpreadPropsLast = createRule21({
|
|
|
1793
2250
|
var jsx_spread_props_last_default = jsxSpreadPropsLast;
|
|
1794
2251
|
|
|
1795
2252
|
// src/rules/newline-after-multiline-block.ts
|
|
1796
|
-
var
|
|
1797
|
-
var
|
|
2253
|
+
var import_utils34 = require("@typescript-eslint/utils");
|
|
2254
|
+
var createRule26 = import_utils34.ESLintUtils.RuleCreator(
|
|
1798
2255
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1799
2256
|
);
|
|
1800
2257
|
function isImportDeclaration(node) {
|
|
1801
|
-
return node.type ===
|
|
2258
|
+
return node.type === import_utils34.AST_NODE_TYPES.ImportDeclaration;
|
|
1802
2259
|
}
|
|
1803
2260
|
function checkStatements(statements, context) {
|
|
1804
2261
|
const { sourceCode } = context;
|
|
@@ -1833,7 +2290,7 @@ function checkStatements(statements, context) {
|
|
|
1833
2290
|
}
|
|
1834
2291
|
});
|
|
1835
2292
|
}
|
|
1836
|
-
var newlineAfterMultilineBlock =
|
|
2293
|
+
var newlineAfterMultilineBlock = createRule26({
|
|
1837
2294
|
name: "newline-after-multiline-block",
|
|
1838
2295
|
meta: {
|
|
1839
2296
|
type: "layout",
|
|
@@ -1861,11 +2318,11 @@ var newlineAfterMultilineBlock = createRule22({
|
|
|
1861
2318
|
var newline_after_multiline_block_default = newlineAfterMultilineBlock;
|
|
1862
2319
|
|
|
1863
2320
|
// src/rules/newline-before-return.ts
|
|
1864
|
-
var
|
|
1865
|
-
var
|
|
2321
|
+
var import_utils35 = require("@typescript-eslint/utils");
|
|
2322
|
+
var createRule27 = import_utils35.ESLintUtils.RuleCreator(
|
|
1866
2323
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1867
2324
|
);
|
|
1868
|
-
var newlineBeforeReturn =
|
|
2325
|
+
var newlineBeforeReturn = createRule27({
|
|
1869
2326
|
name: "newline-before-return",
|
|
1870
2327
|
meta: {
|
|
1871
2328
|
type: "layout",
|
|
@@ -1883,7 +2340,7 @@ var newlineBeforeReturn = createRule23({
|
|
|
1883
2340
|
const { sourceCode } = context;
|
|
1884
2341
|
function checkReturnStatement(node) {
|
|
1885
2342
|
const { parent } = node;
|
|
1886
|
-
if (!parent || parent.type !==
|
|
2343
|
+
if (!parent || parent.type !== import_utils35.AST_NODE_TYPES.BlockStatement) {
|
|
1887
2344
|
return;
|
|
1888
2345
|
}
|
|
1889
2346
|
const { body: statements } = parent;
|
|
@@ -1920,11 +2377,11 @@ var newlineBeforeReturn = createRule23({
|
|
|
1920
2377
|
var newline_before_return_default = newlineBeforeReturn;
|
|
1921
2378
|
|
|
1922
2379
|
// src/rules/no-complex-inline-return.ts
|
|
1923
|
-
var
|
|
1924
|
-
var
|
|
2380
|
+
var import_utils36 = require("@typescript-eslint/utils");
|
|
2381
|
+
var createRule28 = import_utils36.ESLintUtils.RuleCreator(
|
|
1925
2382
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1926
2383
|
);
|
|
1927
|
-
var noComplexInlineReturn =
|
|
2384
|
+
var noComplexInlineReturn = createRule28({
|
|
1928
2385
|
name: "no-complex-inline-return",
|
|
1929
2386
|
meta: {
|
|
1930
2387
|
type: "suggestion",
|
|
@@ -1940,13 +2397,13 @@ var noComplexInlineReturn = createRule24({
|
|
|
1940
2397
|
create(context) {
|
|
1941
2398
|
const isComplexExpression = (node) => {
|
|
1942
2399
|
if (!node) return false;
|
|
1943
|
-
if (node.type ===
|
|
2400
|
+
if (node.type === import_utils36.AST_NODE_TYPES.ConditionalExpression) {
|
|
1944
2401
|
return true;
|
|
1945
2402
|
}
|
|
1946
|
-
if (node.type ===
|
|
2403
|
+
if (node.type === import_utils36.AST_NODE_TYPES.LogicalExpression) {
|
|
1947
2404
|
return true;
|
|
1948
2405
|
}
|
|
1949
|
-
if (node.type ===
|
|
2406
|
+
if (node.type === import_utils36.AST_NODE_TYPES.NewExpression) {
|
|
1950
2407
|
return true;
|
|
1951
2408
|
}
|
|
1952
2409
|
return false;
|
|
@@ -1966,11 +2423,11 @@ var noComplexInlineReturn = createRule24({
|
|
|
1966
2423
|
var no_complex_inline_return_default = noComplexInlineReturn;
|
|
1967
2424
|
|
|
1968
2425
|
// src/rules/no-direct-date.ts
|
|
1969
|
-
var
|
|
1970
|
-
var
|
|
2426
|
+
var import_utils37 = require("@typescript-eslint/utils");
|
|
2427
|
+
var createRule29 = import_utils37.ESLintUtils.RuleCreator(
|
|
1971
2428
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1972
2429
|
);
|
|
1973
|
-
var noDirectDate =
|
|
2430
|
+
var noDirectDate = createRule29({
|
|
1974
2431
|
name: "no-direct-date",
|
|
1975
2432
|
meta: {
|
|
1976
2433
|
type: "problem",
|
|
@@ -1988,7 +2445,7 @@ var noDirectDate = createRule25({
|
|
|
1988
2445
|
create(context) {
|
|
1989
2446
|
return {
|
|
1990
2447
|
NewExpression(node) {
|
|
1991
|
-
if (node.callee.type ===
|
|
2448
|
+
if (node.callee.type === import_utils37.AST_NODE_TYPES.Identifier && node.callee.name === "Date") {
|
|
1992
2449
|
context.report({
|
|
1993
2450
|
node,
|
|
1994
2451
|
messageId: "noNewDate"
|
|
@@ -1996,7 +2453,7 @@ var noDirectDate = createRule25({
|
|
|
1996
2453
|
}
|
|
1997
2454
|
},
|
|
1998
2455
|
CallExpression(node) {
|
|
1999
|
-
if (node.callee.type ===
|
|
2456
|
+
if (node.callee.type === import_utils37.AST_NODE_TYPES.MemberExpression && node.callee.object.type === import_utils37.AST_NODE_TYPES.Identifier && node.callee.object.name === "Date" && node.callee.property.type === import_utils37.AST_NODE_TYPES.Identifier) {
|
|
2000
2457
|
const methodName = node.callee.property.name;
|
|
2001
2458
|
if (methodName === "now") {
|
|
2002
2459
|
context.report({
|
|
@@ -2019,11 +2476,11 @@ var no_direct_date_default = noDirectDate;
|
|
|
2019
2476
|
|
|
2020
2477
|
// src/rules/no-emoji.ts
|
|
2021
2478
|
var import_emoji_regex = __toESM(require("emoji-regex"), 1);
|
|
2022
|
-
var
|
|
2023
|
-
var
|
|
2479
|
+
var import_utils38 = require("@typescript-eslint/utils");
|
|
2480
|
+
var createRule30 = import_utils38.ESLintUtils.RuleCreator(
|
|
2024
2481
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2025
2482
|
);
|
|
2026
|
-
var noEmoji =
|
|
2483
|
+
var noEmoji = createRule30({
|
|
2027
2484
|
name: "no-emoji",
|
|
2028
2485
|
meta: {
|
|
2029
2486
|
type: "problem",
|
|
@@ -2057,11 +2514,11 @@ var noEmoji = createRule26({
|
|
|
2057
2514
|
var no_emoji_default = noEmoji;
|
|
2058
2515
|
|
|
2059
2516
|
// src/rules/no-env-fallback.ts
|
|
2060
|
-
var
|
|
2061
|
-
var
|
|
2517
|
+
var import_utils39 = require("@typescript-eslint/utils");
|
|
2518
|
+
var createRule31 = import_utils39.ESLintUtils.RuleCreator(
|
|
2062
2519
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2063
2520
|
);
|
|
2064
|
-
var noEnvFallback =
|
|
2521
|
+
var noEnvFallback = createRule31({
|
|
2065
2522
|
name: "no-env-fallback",
|
|
2066
2523
|
meta: {
|
|
2067
2524
|
type: "problem",
|
|
@@ -2076,16 +2533,16 @@ var noEnvFallback = createRule27({
|
|
|
2076
2533
|
defaultOptions: [],
|
|
2077
2534
|
create(context) {
|
|
2078
2535
|
const isProcessEnvAccess = (node) => {
|
|
2079
|
-
if (node.type !==
|
|
2536
|
+
if (node.type !== import_utils39.AST_NODE_TYPES.MemberExpression) {
|
|
2080
2537
|
return false;
|
|
2081
2538
|
}
|
|
2082
2539
|
const { object } = node;
|
|
2083
|
-
if (object.type !==
|
|
2540
|
+
if (object.type !== import_utils39.AST_NODE_TYPES.MemberExpression) {
|
|
2084
2541
|
return false;
|
|
2085
2542
|
}
|
|
2086
2543
|
const processNode = object.object;
|
|
2087
2544
|
const envNode = object.property;
|
|
2088
|
-
return processNode.type ===
|
|
2545
|
+
return processNode.type === import_utils39.AST_NODE_TYPES.Identifier && processNode.name === "process" && envNode.type === import_utils39.AST_NODE_TYPES.Identifier && envNode.name === "env";
|
|
2089
2546
|
};
|
|
2090
2547
|
return {
|
|
2091
2548
|
LogicalExpression(node) {
|
|
@@ -2110,15 +2567,15 @@ var noEnvFallback = createRule27({
|
|
|
2110
2567
|
var no_env_fallback_default = noEnvFallback;
|
|
2111
2568
|
|
|
2112
2569
|
// src/rules/no-ghost-wrapper.ts
|
|
2113
|
-
var
|
|
2114
|
-
var
|
|
2570
|
+
var import_utils40 = require("@typescript-eslint/utils");
|
|
2571
|
+
var createRule32 = import_utils40.ESLintUtils.RuleCreator(
|
|
2115
2572
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2116
2573
|
);
|
|
2117
2574
|
var GHOST_TAGS = /* @__PURE__ */ new Set(["div", "span"]);
|
|
2118
2575
|
function isKeyAttribute(attribute) {
|
|
2119
|
-
return attribute.type ===
|
|
2576
|
+
return attribute.type === import_utils40.AST_NODE_TYPES.JSXAttribute && attribute.name.type === import_utils40.AST_NODE_TYPES.JSXIdentifier && attribute.name.name === "key";
|
|
2120
2577
|
}
|
|
2121
|
-
var noGhostWrapper =
|
|
2578
|
+
var noGhostWrapper = createRule32({
|
|
2122
2579
|
name: "no-ghost-wrapper",
|
|
2123
2580
|
meta: {
|
|
2124
2581
|
type: "problem",
|
|
@@ -2134,7 +2591,7 @@ var noGhostWrapper = createRule28({
|
|
|
2134
2591
|
create(context) {
|
|
2135
2592
|
return {
|
|
2136
2593
|
JSXOpeningElement(node) {
|
|
2137
|
-
if (node.name.type !==
|
|
2594
|
+
if (node.name.type !== import_utils40.AST_NODE_TYPES.JSXIdentifier) {
|
|
2138
2595
|
return;
|
|
2139
2596
|
}
|
|
2140
2597
|
const tagName = node.name.name;
|
|
@@ -2156,11 +2613,11 @@ var noGhostWrapper = createRule28({
|
|
|
2156
2613
|
var no_ghost_wrapper_default = noGhostWrapper;
|
|
2157
2614
|
|
|
2158
2615
|
// src/rules/no-inline-default-export.ts
|
|
2159
|
-
var
|
|
2160
|
-
var
|
|
2616
|
+
var import_utils41 = require("@typescript-eslint/utils");
|
|
2617
|
+
var createRule33 = import_utils41.ESLintUtils.RuleCreator(
|
|
2161
2618
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2162
2619
|
);
|
|
2163
|
-
var noInlineDefaultExport =
|
|
2620
|
+
var noInlineDefaultExport = createRule33({
|
|
2164
2621
|
name: "no-inline-default-export",
|
|
2165
2622
|
meta: {
|
|
2166
2623
|
type: "suggestion",
|
|
@@ -2179,7 +2636,7 @@ var noInlineDefaultExport = createRule29({
|
|
|
2179
2636
|
return {
|
|
2180
2637
|
ExportDefaultDeclaration(node) {
|
|
2181
2638
|
const { declaration } = node;
|
|
2182
|
-
if (declaration.type ===
|
|
2639
|
+
if (declaration.type === import_utils41.AST_NODE_TYPES.FunctionDeclaration) {
|
|
2183
2640
|
if (declaration.id) {
|
|
2184
2641
|
context.report({
|
|
2185
2642
|
node,
|
|
@@ -2194,7 +2651,7 @@ var noInlineDefaultExport = createRule29({
|
|
|
2194
2651
|
});
|
|
2195
2652
|
}
|
|
2196
2653
|
}
|
|
2197
|
-
if (declaration.type ===
|
|
2654
|
+
if (declaration.type === import_utils41.AST_NODE_TYPES.ClassDeclaration) {
|
|
2198
2655
|
if (declaration.id) {
|
|
2199
2656
|
context.report({
|
|
2200
2657
|
node,
|
|
@@ -2209,7 +2666,7 @@ var noInlineDefaultExport = createRule29({
|
|
|
2209
2666
|
});
|
|
2210
2667
|
}
|
|
2211
2668
|
}
|
|
2212
|
-
if (declaration.type ===
|
|
2669
|
+
if (declaration.type === import_utils41.AST_NODE_TYPES.ArrowFunctionExpression || declaration.type === import_utils41.AST_NODE_TYPES.FunctionExpression) {
|
|
2213
2670
|
context.report({
|
|
2214
2671
|
node,
|
|
2215
2672
|
messageId: "noAnonymousDefaultExport",
|
|
@@ -2222,14 +2679,14 @@ var noInlineDefaultExport = createRule29({
|
|
|
2222
2679
|
if (!declaration) {
|
|
2223
2680
|
return;
|
|
2224
2681
|
}
|
|
2225
|
-
if (declaration.type ===
|
|
2682
|
+
if (declaration.type === import_utils41.AST_NODE_TYPES.FunctionDeclaration && declaration.id) {
|
|
2226
2683
|
context.report({
|
|
2227
2684
|
node,
|
|
2228
2685
|
messageId: "noInlineNamedExport",
|
|
2229
2686
|
data: { type: "function", name: declaration.id.name }
|
|
2230
2687
|
});
|
|
2231
2688
|
}
|
|
2232
|
-
if (declaration.type ===
|
|
2689
|
+
if (declaration.type === import_utils41.AST_NODE_TYPES.ClassDeclaration && declaration.id) {
|
|
2233
2690
|
context.report({
|
|
2234
2691
|
node,
|
|
2235
2692
|
messageId: "noInlineNamedExport",
|
|
@@ -2243,27 +2700,27 @@ var noInlineDefaultExport = createRule29({
|
|
|
2243
2700
|
var no_inline_default_export_default = noInlineDefaultExport;
|
|
2244
2701
|
|
|
2245
2702
|
// src/rules/no-inline-nested-object.ts
|
|
2246
|
-
var
|
|
2247
|
-
var
|
|
2703
|
+
var import_utils42 = require("@typescript-eslint/utils");
|
|
2704
|
+
var createRule34 = import_utils42.ESLintUtils.RuleCreator(
|
|
2248
2705
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2249
2706
|
);
|
|
2250
2707
|
function isObjectOrArray(node) {
|
|
2251
|
-
return node.type ===
|
|
2708
|
+
return node.type === import_utils42.AST_NODE_TYPES.ObjectExpression || node.type === import_utils42.AST_NODE_TYPES.ArrayExpression || node.type === import_utils42.AST_NODE_TYPES.TSAsExpression;
|
|
2252
2709
|
}
|
|
2253
2710
|
function getInnerExpression(node) {
|
|
2254
|
-
if (node.type ===
|
|
2711
|
+
if (node.type === import_utils42.AST_NODE_TYPES.TSAsExpression) {
|
|
2255
2712
|
return getInnerExpression(node.expression);
|
|
2256
2713
|
}
|
|
2257
2714
|
return node;
|
|
2258
2715
|
}
|
|
2259
2716
|
function isNestedStructure(node) {
|
|
2260
2717
|
const inner = getInnerExpression(node);
|
|
2261
|
-
return inner.type ===
|
|
2718
|
+
return inner.type === import_utils42.AST_NODE_TYPES.ObjectExpression || inner.type === import_utils42.AST_NODE_TYPES.ArrayExpression;
|
|
2262
2719
|
}
|
|
2263
2720
|
function containsNestedStructure(node) {
|
|
2264
|
-
if (node.type ===
|
|
2721
|
+
if (node.type === import_utils42.AST_NODE_TYPES.ObjectExpression) {
|
|
2265
2722
|
return node.properties.some((prop) => {
|
|
2266
|
-
if (prop.type !==
|
|
2723
|
+
if (prop.type !== import_utils42.AST_NODE_TYPES.Property) return false;
|
|
2267
2724
|
return isNestedStructure(prop.value);
|
|
2268
2725
|
});
|
|
2269
2726
|
}
|
|
@@ -2272,7 +2729,7 @@ function containsNestedStructure(node) {
|
|
|
2272
2729
|
return isNestedStructure(el);
|
|
2273
2730
|
});
|
|
2274
2731
|
}
|
|
2275
|
-
var noInlineNestedObject =
|
|
2732
|
+
var noInlineNestedObject = createRule34({
|
|
2276
2733
|
name: "no-inline-nested-object",
|
|
2277
2734
|
meta: {
|
|
2278
2735
|
type: "layout",
|
|
@@ -2294,7 +2751,7 @@ var noInlineNestedObject = createRule30({
|
|
|
2294
2751
|
return;
|
|
2295
2752
|
}
|
|
2296
2753
|
const valueNode = getInnerExpression(node.value);
|
|
2297
|
-
if (valueNode.type !==
|
|
2754
|
+
if (valueNode.type !== import_utils42.AST_NODE_TYPES.ObjectExpression && valueNode.type !== import_utils42.AST_NODE_TYPES.ArrayExpression) {
|
|
2298
2755
|
return;
|
|
2299
2756
|
}
|
|
2300
2757
|
if (!valueNode.loc) {
|
|
@@ -2307,7 +2764,7 @@ var noInlineNestedObject = createRule30({
|
|
|
2307
2764
|
if (!containsNestedStructure(valueNode)) {
|
|
2308
2765
|
return;
|
|
2309
2766
|
}
|
|
2310
|
-
const elements = valueNode.type ===
|
|
2767
|
+
const elements = valueNode.type === import_utils42.AST_NODE_TYPES.ObjectExpression ? valueNode.properties : valueNode.elements;
|
|
2311
2768
|
context.report({
|
|
2312
2769
|
node: valueNode,
|
|
2313
2770
|
messageId: "requireMultiline",
|
|
@@ -2320,7 +2777,7 @@ var noInlineNestedObject = createRule30({
|
|
|
2320
2777
|
const indent = " ".repeat(node.loc?.start.column ?? 0);
|
|
2321
2778
|
const innerIndent = `${indent} `;
|
|
2322
2779
|
const elementTexts = elements.filter((el) => el !== null).map((el) => sourceCode.getText(el));
|
|
2323
|
-
const isObject = valueNode.type ===
|
|
2780
|
+
const isObject = valueNode.type === import_utils42.AST_NODE_TYPES.ObjectExpression;
|
|
2324
2781
|
const openChar = isObject ? "{" : "[";
|
|
2325
2782
|
const closeChar = isObject ? "}" : "]";
|
|
2326
2783
|
const formattedElements = elementTexts.map((text) => `${innerIndent}${text},`).join("\n");
|
|
@@ -2337,20 +2794,20 @@ ${indent}${closeChar}`;
|
|
|
2337
2794
|
var no_inline_nested_object_default = noInlineNestedObject;
|
|
2338
2795
|
|
|
2339
2796
|
// src/rules/no-inline-return-properties.ts
|
|
2340
|
-
var
|
|
2341
|
-
var
|
|
2797
|
+
var import_utils43 = require("@typescript-eslint/utils");
|
|
2798
|
+
var createRule35 = import_utils43.ESLintUtils.RuleCreator(
|
|
2342
2799
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2343
2800
|
);
|
|
2344
2801
|
var isShorthandProperty = (property) => {
|
|
2345
|
-
if (property.type ===
|
|
2802
|
+
if (property.type === import_utils43.AST_NODE_TYPES.SpreadElement) {
|
|
2346
2803
|
return true;
|
|
2347
2804
|
}
|
|
2348
|
-
if (property.type !==
|
|
2805
|
+
if (property.type !== import_utils43.AST_NODE_TYPES.Property) {
|
|
2349
2806
|
return false;
|
|
2350
2807
|
}
|
|
2351
2808
|
return property.shorthand;
|
|
2352
2809
|
};
|
|
2353
|
-
var noInlineReturnProperties =
|
|
2810
|
+
var noInlineReturnProperties = createRule35({
|
|
2354
2811
|
name: "no-inline-return-properties",
|
|
2355
2812
|
meta: {
|
|
2356
2813
|
type: "suggestion",
|
|
@@ -2366,20 +2823,20 @@ var noInlineReturnProperties = createRule31({
|
|
|
2366
2823
|
create(context) {
|
|
2367
2824
|
return {
|
|
2368
2825
|
ReturnStatement(node) {
|
|
2369
|
-
if (!node.argument || node.argument.type !==
|
|
2826
|
+
if (!node.argument || node.argument.type !== import_utils43.AST_NODE_TYPES.ObjectExpression) {
|
|
2370
2827
|
return;
|
|
2371
2828
|
}
|
|
2372
2829
|
node.argument.properties.forEach((property) => {
|
|
2373
2830
|
if (isShorthandProperty(property)) {
|
|
2374
2831
|
return;
|
|
2375
2832
|
}
|
|
2376
|
-
if (property.type !==
|
|
2833
|
+
if (property.type !== import_utils43.AST_NODE_TYPES.Property) {
|
|
2377
2834
|
return;
|
|
2378
2835
|
}
|
|
2379
2836
|
let keyName = null;
|
|
2380
|
-
if (property.key.type ===
|
|
2837
|
+
if (property.key.type === import_utils43.AST_NODE_TYPES.Identifier) {
|
|
2381
2838
|
keyName = property.key.name;
|
|
2382
|
-
} else if (property.key.type ===
|
|
2839
|
+
} else if (property.key.type === import_utils43.AST_NODE_TYPES.Literal) {
|
|
2383
2840
|
keyName = String(property.key.value);
|
|
2384
2841
|
}
|
|
2385
2842
|
context.report({
|
|
@@ -2395,12 +2852,12 @@ var noInlineReturnProperties = createRule31({
|
|
|
2395
2852
|
var no_inline_return_properties_default = noInlineReturnProperties;
|
|
2396
2853
|
|
|
2397
2854
|
// src/rules/no-inline-type-import.ts
|
|
2398
|
-
var
|
|
2399
|
-
var
|
|
2855
|
+
var import_utils44 = require("@typescript-eslint/utils");
|
|
2856
|
+
var createRule36 = import_utils44.ESLintUtils.RuleCreator(
|
|
2400
2857
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2401
2858
|
);
|
|
2402
|
-
var isInlineTypeSpecifier = (specifier) => specifier.type ===
|
|
2403
|
-
var noInlineTypeImport =
|
|
2859
|
+
var isInlineTypeSpecifier = (specifier) => specifier.type === import_utils44.AST_NODE_TYPES.ImportSpecifier && specifier.importKind === "type";
|
|
2860
|
+
var noInlineTypeImport = createRule36({
|
|
2404
2861
|
name: "no-inline-type-import",
|
|
2405
2862
|
meta: {
|
|
2406
2863
|
type: "suggestion",
|
|
@@ -2437,7 +2894,7 @@ var noInlineTypeImport = createRule32({
|
|
|
2437
2894
|
);
|
|
2438
2895
|
const typeImport = `import type { ${typeSpecifierTexts.join(", ")} } from ${sourceText};`;
|
|
2439
2896
|
const valueSpecifiers = node.specifiers.filter(
|
|
2440
|
-
(specifier) => !(specifier.type ===
|
|
2897
|
+
(specifier) => !(specifier.type === import_utils44.AST_NODE_TYPES.ImportSpecifier && specifier.importKind === "type")
|
|
2441
2898
|
);
|
|
2442
2899
|
if (valueSpecifiers.length === 0) {
|
|
2443
2900
|
return fixer.replaceText(node, typeImport);
|
|
@@ -2445,11 +2902,11 @@ var noInlineTypeImport = createRule32({
|
|
|
2445
2902
|
const parts = [];
|
|
2446
2903
|
const namedValueSpecifiers = [];
|
|
2447
2904
|
for (const specifier of valueSpecifiers) {
|
|
2448
|
-
if (specifier.type ===
|
|
2905
|
+
if (specifier.type === import_utils44.AST_NODE_TYPES.ImportDefaultSpecifier) {
|
|
2449
2906
|
parts.push(specifier.local.name);
|
|
2450
|
-
} else if (specifier.type ===
|
|
2907
|
+
} else if (specifier.type === import_utils44.AST_NODE_TYPES.ImportNamespaceSpecifier) {
|
|
2451
2908
|
parts.push(`* as ${specifier.local.name}`);
|
|
2452
|
-
} else if (specifier.type ===
|
|
2909
|
+
} else if (specifier.type === import_utils44.AST_NODE_TYPES.ImportSpecifier) {
|
|
2453
2910
|
namedValueSpecifiers.push(specifier);
|
|
2454
2911
|
}
|
|
2455
2912
|
}
|
|
@@ -2469,8 +2926,8 @@ ${typeImport}`);
|
|
|
2469
2926
|
var no_inline_type_import_default = noInlineTypeImport;
|
|
2470
2927
|
|
|
2471
2928
|
// src/rules/no-lazy-identifiers.ts
|
|
2472
|
-
var
|
|
2473
|
-
var
|
|
2929
|
+
var import_utils45 = require("@typescript-eslint/utils");
|
|
2930
|
+
var createRule37 = import_utils45.ESLintUtils.RuleCreator(
|
|
2474
2931
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2475
2932
|
);
|
|
2476
2933
|
var KEYBOARD_ROWS = ["qwertyuiop", "asdfghjkl", "zxcvbnm", "1234567890"];
|
|
@@ -2511,7 +2968,7 @@ var isLazyIdentifier = (name) => {
|
|
|
2511
2968
|
}
|
|
2512
2969
|
return false;
|
|
2513
2970
|
};
|
|
2514
|
-
var noLazyIdentifiers =
|
|
2971
|
+
var noLazyIdentifiers = createRule37({
|
|
2515
2972
|
name: "no-lazy-identifiers",
|
|
2516
2973
|
meta: {
|
|
2517
2974
|
type: "problem",
|
|
@@ -2537,27 +2994,27 @@ var noLazyIdentifiers = createRule33({
|
|
|
2537
2994
|
});
|
|
2538
2995
|
};
|
|
2539
2996
|
const checkPattern = (pattern) => {
|
|
2540
|
-
if (pattern.type ===
|
|
2997
|
+
if (pattern.type === import_utils45.AST_NODE_TYPES.Identifier) {
|
|
2541
2998
|
checkIdentifier(pattern);
|
|
2542
|
-
} else if (pattern.type ===
|
|
2999
|
+
} else if (pattern.type === import_utils45.AST_NODE_TYPES.ObjectPattern) {
|
|
2543
3000
|
pattern.properties.forEach((prop) => {
|
|
2544
|
-
if (prop.type ===
|
|
3001
|
+
if (prop.type === import_utils45.AST_NODE_TYPES.Property && prop.value.type === import_utils45.AST_NODE_TYPES.Identifier) {
|
|
2545
3002
|
checkIdentifier(prop.value);
|
|
2546
|
-
} else if (prop.type ===
|
|
3003
|
+
} else if (prop.type === import_utils45.AST_NODE_TYPES.RestElement && prop.argument.type === import_utils45.AST_NODE_TYPES.Identifier) {
|
|
2547
3004
|
checkIdentifier(prop.argument);
|
|
2548
3005
|
}
|
|
2549
3006
|
});
|
|
2550
|
-
} else if (pattern.type ===
|
|
3007
|
+
} else if (pattern.type === import_utils45.AST_NODE_TYPES.ArrayPattern) {
|
|
2551
3008
|
pattern.elements.forEach((element) => {
|
|
2552
|
-
if (element?.type ===
|
|
3009
|
+
if (element?.type === import_utils45.AST_NODE_TYPES.Identifier) {
|
|
2553
3010
|
checkIdentifier(element);
|
|
2554
|
-
} else if (element?.type ===
|
|
3011
|
+
} else if (element?.type === import_utils45.AST_NODE_TYPES.RestElement && element.argument.type === import_utils45.AST_NODE_TYPES.Identifier) {
|
|
2555
3012
|
checkIdentifier(element.argument);
|
|
2556
3013
|
}
|
|
2557
3014
|
});
|
|
2558
|
-
} else if (pattern.type ===
|
|
3015
|
+
} else if (pattern.type === import_utils45.AST_NODE_TYPES.AssignmentPattern && pattern.left.type === import_utils45.AST_NODE_TYPES.Identifier) {
|
|
2559
3016
|
checkIdentifier(pattern.left);
|
|
2560
|
-
} else if (pattern.type ===
|
|
3017
|
+
} else if (pattern.type === import_utils45.AST_NODE_TYPES.RestElement && pattern.argument.type === import_utils45.AST_NODE_TYPES.Identifier) {
|
|
2561
3018
|
checkIdentifier(pattern.argument);
|
|
2562
3019
|
}
|
|
2563
3020
|
};
|
|
@@ -2602,11 +3059,11 @@ var noLazyIdentifiers = createRule33({
|
|
|
2602
3059
|
var no_lazy_identifiers_default = noLazyIdentifiers;
|
|
2603
3060
|
|
|
2604
3061
|
// src/rules/no-logic-in-params.ts
|
|
2605
|
-
var
|
|
2606
|
-
var
|
|
3062
|
+
var import_utils46 = require("@typescript-eslint/utils");
|
|
3063
|
+
var createRule38 = import_utils46.ESLintUtils.RuleCreator(
|
|
2607
3064
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2608
3065
|
);
|
|
2609
|
-
var noLogicInParams =
|
|
3066
|
+
var noLogicInParams = createRule38({
|
|
2610
3067
|
name: "no-logic-in-params",
|
|
2611
3068
|
meta: {
|
|
2612
3069
|
type: "suggestion",
|
|
@@ -2621,20 +3078,20 @@ var noLogicInParams = createRule34({
|
|
|
2621
3078
|
defaultOptions: [],
|
|
2622
3079
|
create(context) {
|
|
2623
3080
|
const isComplexExpression = (node) => {
|
|
2624
|
-
if (node.type ===
|
|
3081
|
+
if (node.type === import_utils46.AST_NODE_TYPES.SpreadElement) {
|
|
2625
3082
|
return false;
|
|
2626
3083
|
}
|
|
2627
|
-
if (node.type ===
|
|
3084
|
+
if (node.type === import_utils46.AST_NODE_TYPES.ConditionalExpression) {
|
|
2628
3085
|
return true;
|
|
2629
3086
|
}
|
|
2630
|
-
if (node.type ===
|
|
3087
|
+
if (node.type === import_utils46.AST_NODE_TYPES.LogicalExpression) {
|
|
2631
3088
|
return true;
|
|
2632
3089
|
}
|
|
2633
|
-
if (node.type ===
|
|
3090
|
+
if (node.type === import_utils46.AST_NODE_TYPES.BinaryExpression) {
|
|
2634
3091
|
const logicalOperators = ["==", "===", "!=", "!==", "<", ">", "<=", ">=", "in", "instanceof"];
|
|
2635
3092
|
return logicalOperators.includes(node.operator);
|
|
2636
3093
|
}
|
|
2637
|
-
if (node.type ===
|
|
3094
|
+
if (node.type === import_utils46.AST_NODE_TYPES.UnaryExpression) {
|
|
2638
3095
|
return node.operator === "!";
|
|
2639
3096
|
}
|
|
2640
3097
|
return false;
|
|
@@ -2647,7 +3104,7 @@ var noLogicInParams = createRule34({
|
|
|
2647
3104
|
messageId: "noLogicInParams"
|
|
2648
3105
|
});
|
|
2649
3106
|
}
|
|
2650
|
-
if (arg.type ===
|
|
3107
|
+
if (arg.type === import_utils46.AST_NODE_TYPES.ArrayExpression) {
|
|
2651
3108
|
arg.elements.forEach((element) => {
|
|
2652
3109
|
if (element && isComplexExpression(element)) {
|
|
2653
3110
|
context.report({
|
|
@@ -2672,46 +3129,46 @@ var noLogicInParams = createRule34({
|
|
|
2672
3129
|
var no_logic_in_params_default = noLogicInParams;
|
|
2673
3130
|
|
|
2674
3131
|
// src/rules/no-misleading-constant-case.ts
|
|
2675
|
-
var
|
|
2676
|
-
var
|
|
3132
|
+
var import_utils47 = require("@typescript-eslint/utils");
|
|
3133
|
+
var createRule39 = import_utils47.ESLintUtils.RuleCreator(
|
|
2677
3134
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2678
3135
|
);
|
|
2679
3136
|
var SCREAMING_SNAKE_CASE_REGEX3 = /^[A-Z][A-Z0-9]*(?:_[A-Z0-9]+)*$/;
|
|
2680
|
-
var isAsConstAssertion = (node) => node.type ===
|
|
3137
|
+
var isAsConstAssertion = (node) => node.type === import_utils47.AST_NODE_TYPES.TSAsExpression && node.typeAnnotation.type === import_utils47.AST_NODE_TYPES.TSTypeReference && node.typeAnnotation.typeName.type === import_utils47.AST_NODE_TYPES.Identifier && node.typeAnnotation.typeName.name === "const";
|
|
2681
3138
|
var isStaticValue2 = (init) => {
|
|
2682
3139
|
if (isAsConstAssertion(init)) {
|
|
2683
3140
|
return true;
|
|
2684
3141
|
}
|
|
2685
|
-
if (init.type ===
|
|
3142
|
+
if (init.type === import_utils47.AST_NODE_TYPES.Literal) {
|
|
2686
3143
|
return true;
|
|
2687
3144
|
}
|
|
2688
|
-
if (init.type ===
|
|
3145
|
+
if (init.type === import_utils47.AST_NODE_TYPES.UnaryExpression && init.argument.type === import_utils47.AST_NODE_TYPES.Literal) {
|
|
2689
3146
|
return true;
|
|
2690
3147
|
}
|
|
2691
|
-
if (init.type ===
|
|
3148
|
+
if (init.type === import_utils47.AST_NODE_TYPES.TemplateLiteral && init.expressions.length === 0) {
|
|
2692
3149
|
return true;
|
|
2693
3150
|
}
|
|
2694
|
-
if (init.type ===
|
|
2695
|
-
return init.elements.every((el) => el !== null && el.type !==
|
|
3151
|
+
if (init.type === import_utils47.AST_NODE_TYPES.ArrayExpression) {
|
|
3152
|
+
return init.elements.every((el) => el !== null && el.type !== import_utils47.AST_NODE_TYPES.SpreadElement && isStaticValue2(el));
|
|
2696
3153
|
}
|
|
2697
|
-
if (init.type ===
|
|
3154
|
+
if (init.type === import_utils47.AST_NODE_TYPES.ObjectExpression) {
|
|
2698
3155
|
return init.properties.every(
|
|
2699
|
-
(prop) => prop.type ===
|
|
3156
|
+
(prop) => prop.type === import_utils47.AST_NODE_TYPES.Property && isStaticValue2(prop.value)
|
|
2700
3157
|
);
|
|
2701
3158
|
}
|
|
2702
3159
|
return false;
|
|
2703
3160
|
};
|
|
2704
3161
|
var isGlobalScope3 = (node) => {
|
|
2705
3162
|
const { parent } = node;
|
|
2706
|
-
if (parent.type ===
|
|
3163
|
+
if (parent.type === import_utils47.AST_NODE_TYPES.Program) {
|
|
2707
3164
|
return true;
|
|
2708
3165
|
}
|
|
2709
|
-
if (parent.type ===
|
|
3166
|
+
if (parent.type === import_utils47.AST_NODE_TYPES.ExportNamedDeclaration && parent.parent?.type === import_utils47.AST_NODE_TYPES.Program) {
|
|
2710
3167
|
return true;
|
|
2711
3168
|
}
|
|
2712
3169
|
return false;
|
|
2713
3170
|
};
|
|
2714
|
-
var noMisleadingConstantCase =
|
|
3171
|
+
var noMisleadingConstantCase = createRule39({
|
|
2715
3172
|
name: "no-misleading-constant-case",
|
|
2716
3173
|
meta: {
|
|
2717
3174
|
type: "suggestion",
|
|
@@ -2730,7 +3187,7 @@ var noMisleadingConstantCase = createRule35({
|
|
|
2730
3187
|
return {
|
|
2731
3188
|
VariableDeclaration(node) {
|
|
2732
3189
|
node.declarations.forEach((declarator) => {
|
|
2733
|
-
if (declarator.id.type !==
|
|
3190
|
+
if (declarator.id.type !== import_utils47.AST_NODE_TYPES.Identifier) {
|
|
2734
3191
|
return;
|
|
2735
3192
|
}
|
|
2736
3193
|
const { name } = declarator.id;
|
|
@@ -2771,11 +3228,11 @@ var noMisleadingConstantCase = createRule35({
|
|
|
2771
3228
|
var no_misleading_constant_case_default = noMisleadingConstantCase;
|
|
2772
3229
|
|
|
2773
3230
|
// src/rules/no-nested-interface-declaration.ts
|
|
2774
|
-
var
|
|
2775
|
-
var
|
|
3231
|
+
var import_utils48 = require("@typescript-eslint/utils");
|
|
3232
|
+
var createRule40 = import_utils48.ESLintUtils.RuleCreator(
|
|
2776
3233
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2777
3234
|
);
|
|
2778
|
-
var noNestedInterfaceDeclaration =
|
|
3235
|
+
var noNestedInterfaceDeclaration = createRule40({
|
|
2779
3236
|
name: "no-nested-interface-declaration",
|
|
2780
3237
|
meta: {
|
|
2781
3238
|
type: "suggestion",
|
|
@@ -2796,15 +3253,15 @@ var noNestedInterfaceDeclaration = createRule36({
|
|
|
2796
3253
|
return;
|
|
2797
3254
|
}
|
|
2798
3255
|
const { typeAnnotation } = node.typeAnnotation;
|
|
2799
|
-
if (typeAnnotation.type ===
|
|
3256
|
+
if (typeAnnotation.type === import_utils48.AST_NODE_TYPES.TSTypeLiteral) {
|
|
2800
3257
|
context.report({
|
|
2801
3258
|
node: typeAnnotation,
|
|
2802
3259
|
messageId: "noNestedInterface"
|
|
2803
3260
|
});
|
|
2804
3261
|
return;
|
|
2805
3262
|
}
|
|
2806
|
-
if (typeAnnotation.type ===
|
|
2807
|
-
if (typeAnnotation.elementType.type ===
|
|
3263
|
+
if (typeAnnotation.type === import_utils48.AST_NODE_TYPES.TSArrayType) {
|
|
3264
|
+
if (typeAnnotation.elementType.type === import_utils48.AST_NODE_TYPES.TSTypeLiteral) {
|
|
2808
3265
|
context.report({
|
|
2809
3266
|
node: typeAnnotation.elementType,
|
|
2810
3267
|
messageId: "noNestedInterface"
|
|
@@ -2812,9 +3269,9 @@ var noNestedInterfaceDeclaration = createRule36({
|
|
|
2812
3269
|
}
|
|
2813
3270
|
return;
|
|
2814
3271
|
}
|
|
2815
|
-
if (typeAnnotation.type ===
|
|
3272
|
+
if (typeAnnotation.type === import_utils48.AST_NODE_TYPES.TSTypeReference && typeAnnotation.typeArguments) {
|
|
2816
3273
|
typeAnnotation.typeArguments.params.forEach((param) => {
|
|
2817
|
-
if (param.type ===
|
|
3274
|
+
if (param.type === import_utils48.AST_NODE_TYPES.TSTypeLiteral) {
|
|
2818
3275
|
context.report({
|
|
2819
3276
|
node: param,
|
|
2820
3277
|
messageId: "noNestedInterface"
|
|
@@ -2829,11 +3286,11 @@ var noNestedInterfaceDeclaration = createRule36({
|
|
|
2829
3286
|
var no_nested_interface_declaration_default = noNestedInterfaceDeclaration;
|
|
2830
3287
|
|
|
2831
3288
|
// src/rules/no-nested-ternary.ts
|
|
2832
|
-
var
|
|
2833
|
-
var
|
|
3289
|
+
var import_utils49 = require("@typescript-eslint/utils");
|
|
3290
|
+
var createRule41 = import_utils49.ESLintUtils.RuleCreator(
|
|
2834
3291
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2835
3292
|
);
|
|
2836
|
-
var noNestedTernary =
|
|
3293
|
+
var noNestedTernary = createRule41({
|
|
2837
3294
|
name: "no-nested-ternary",
|
|
2838
3295
|
meta: {
|
|
2839
3296
|
type: "suggestion",
|
|
@@ -2850,13 +3307,13 @@ var noNestedTernary = createRule37({
|
|
|
2850
3307
|
return {
|
|
2851
3308
|
ConditionalExpression(node) {
|
|
2852
3309
|
const { consequent, alternate } = node;
|
|
2853
|
-
if (consequent.type ===
|
|
3310
|
+
if (consequent.type === import_utils49.AST_NODE_TYPES.ConditionalExpression) {
|
|
2854
3311
|
context.report({
|
|
2855
3312
|
node: consequent,
|
|
2856
3313
|
messageId: "noNestedTernary"
|
|
2857
3314
|
});
|
|
2858
3315
|
}
|
|
2859
|
-
if (alternate.type ===
|
|
3316
|
+
if (alternate.type === import_utils49.AST_NODE_TYPES.ConditionalExpression) {
|
|
2860
3317
|
context.report({
|
|
2861
3318
|
node: alternate,
|
|
2862
3319
|
messageId: "noNestedTernary"
|
|
@@ -2869,33 +3326,33 @@ var noNestedTernary = createRule37({
|
|
|
2869
3326
|
var no_nested_ternary_default = noNestedTernary;
|
|
2870
3327
|
|
|
2871
3328
|
// src/rules/no-redundant-fragment.ts
|
|
2872
|
-
var
|
|
2873
|
-
var
|
|
3329
|
+
var import_utils50 = require("@typescript-eslint/utils");
|
|
3330
|
+
var createRule42 = import_utils50.ESLintUtils.RuleCreator(
|
|
2874
3331
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2875
3332
|
);
|
|
2876
3333
|
function isFragmentName(name) {
|
|
2877
|
-
if (name.type ===
|
|
3334
|
+
if (name.type === import_utils50.AST_NODE_TYPES.JSXIdentifier && name.name === "Fragment") {
|
|
2878
3335
|
return true;
|
|
2879
3336
|
}
|
|
2880
|
-
if (name.type ===
|
|
3337
|
+
if (name.type === import_utils50.AST_NODE_TYPES.JSXMemberExpression && name.object.type === import_utils50.AST_NODE_TYPES.JSXIdentifier && name.object.name === "React" && name.property.type === import_utils50.AST_NODE_TYPES.JSXIdentifier && name.property.name === "Fragment") {
|
|
2881
3338
|
return true;
|
|
2882
3339
|
}
|
|
2883
3340
|
return false;
|
|
2884
3341
|
}
|
|
2885
3342
|
function hasKeyAttribute(attributes) {
|
|
2886
3343
|
return attributes.some(
|
|
2887
|
-
(attribute) => attribute.type ===
|
|
3344
|
+
(attribute) => attribute.type === import_utils50.AST_NODE_TYPES.JSXAttribute && attribute.name.type === import_utils50.AST_NODE_TYPES.JSXIdentifier && attribute.name.name === "key"
|
|
2888
3345
|
);
|
|
2889
3346
|
}
|
|
2890
3347
|
function countMeaningfulChildren(children) {
|
|
2891
3348
|
return children.filter((child) => {
|
|
2892
|
-
if (child.type ===
|
|
3349
|
+
if (child.type === import_utils50.AST_NODE_TYPES.JSXText) {
|
|
2893
3350
|
return child.value.trim() !== "";
|
|
2894
3351
|
}
|
|
2895
3352
|
return true;
|
|
2896
3353
|
}).length;
|
|
2897
3354
|
}
|
|
2898
|
-
var noRedundantFragment =
|
|
3355
|
+
var noRedundantFragment = createRule42({
|
|
2899
3356
|
name: "no-redundant-fragment",
|
|
2900
3357
|
meta: {
|
|
2901
3358
|
type: "problem",
|
|
@@ -2943,11 +3400,11 @@ var noRedundantFragment = createRule38({
|
|
|
2943
3400
|
var no_redundant_fragment_default = noRedundantFragment;
|
|
2944
3401
|
|
|
2945
3402
|
// src/rules/no-relative-imports.ts
|
|
2946
|
-
var
|
|
2947
|
-
var
|
|
3403
|
+
var import_utils51 = require("@typescript-eslint/utils");
|
|
3404
|
+
var createRule43 = import_utils51.ESLintUtils.RuleCreator(
|
|
2948
3405
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2949
3406
|
);
|
|
2950
|
-
var noRelativeImports =
|
|
3407
|
+
var noRelativeImports = createRule43({
|
|
2951
3408
|
name: "no-relative-imports",
|
|
2952
3409
|
meta: {
|
|
2953
3410
|
type: "suggestion",
|
|
@@ -2971,22 +3428,22 @@ var noRelativeImports = createRule39({
|
|
|
2971
3428
|
};
|
|
2972
3429
|
return {
|
|
2973
3430
|
ImportDeclaration(node) {
|
|
2974
|
-
if (node.source.type ===
|
|
3431
|
+
if (node.source.type === import_utils51.AST_NODE_TYPES.Literal && typeof node.source.value === "string") {
|
|
2975
3432
|
checkImportPath(node.source.value, node);
|
|
2976
3433
|
}
|
|
2977
3434
|
},
|
|
2978
3435
|
ImportExpression(node) {
|
|
2979
|
-
if (node.source.type ===
|
|
3436
|
+
if (node.source.type === import_utils51.AST_NODE_TYPES.Literal && typeof node.source.value === "string") {
|
|
2980
3437
|
checkImportPath(node.source.value, node);
|
|
2981
3438
|
}
|
|
2982
3439
|
},
|
|
2983
3440
|
ExportNamedDeclaration(node) {
|
|
2984
|
-
if (node.source?.type ===
|
|
3441
|
+
if (node.source?.type === import_utils51.AST_NODE_TYPES.Literal && typeof node.source.value === "string") {
|
|
2985
3442
|
checkImportPath(node.source.value, node);
|
|
2986
3443
|
}
|
|
2987
3444
|
},
|
|
2988
3445
|
ExportAllDeclaration(node) {
|
|
2989
|
-
if (node.source.type ===
|
|
3446
|
+
if (node.source.type === import_utils51.AST_NODE_TYPES.Literal && typeof node.source.value === "string") {
|
|
2990
3447
|
checkImportPath(node.source.value, node);
|
|
2991
3448
|
}
|
|
2992
3449
|
}
|
|
@@ -2996,8 +3453,8 @@ var noRelativeImports = createRule39({
|
|
|
2996
3453
|
var no_relative_imports_default = noRelativeImports;
|
|
2997
3454
|
|
|
2998
3455
|
// src/rules/no-single-char-variables.ts
|
|
2999
|
-
var
|
|
3000
|
-
var
|
|
3456
|
+
var import_utils52 = require("@typescript-eslint/utils");
|
|
3457
|
+
var createRule44 = import_utils52.ESLintUtils.RuleCreator(
|
|
3001
3458
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3002
3459
|
);
|
|
3003
3460
|
var ALLOWED_IN_FOR_LOOPS = /* @__PURE__ */ new Set(["i", "j", "k", "n"]);
|
|
@@ -3009,7 +3466,7 @@ var isForLoopInit = (node) => {
|
|
|
3009
3466
|
if (!parentNode) {
|
|
3010
3467
|
return false;
|
|
3011
3468
|
}
|
|
3012
|
-
if (parentNode.type ===
|
|
3469
|
+
if (parentNode.type === import_utils52.AST_NODE_TYPES.ForStatement) {
|
|
3013
3470
|
const { init } = parentNode;
|
|
3014
3471
|
if (init && init === current) {
|
|
3015
3472
|
return true;
|
|
@@ -3028,7 +3485,7 @@ var isAllowedInContext = (name, node) => {
|
|
|
3028
3485
|
}
|
|
3029
3486
|
return false;
|
|
3030
3487
|
};
|
|
3031
|
-
var noSingleCharVariables =
|
|
3488
|
+
var noSingleCharVariables = createRule44({
|
|
3032
3489
|
name: "no-single-char-variables",
|
|
3033
3490
|
meta: {
|
|
3034
3491
|
type: "suggestion",
|
|
@@ -3057,27 +3514,27 @@ var noSingleCharVariables = createRule40({
|
|
|
3057
3514
|
});
|
|
3058
3515
|
};
|
|
3059
3516
|
const checkPattern = (pattern, declarationNode) => {
|
|
3060
|
-
if (pattern.type ===
|
|
3517
|
+
if (pattern.type === import_utils52.AST_NODE_TYPES.Identifier) {
|
|
3061
3518
|
checkIdentifier(pattern, declarationNode);
|
|
3062
|
-
} else if (pattern.type ===
|
|
3519
|
+
} else if (pattern.type === import_utils52.AST_NODE_TYPES.ObjectPattern) {
|
|
3063
3520
|
pattern.properties.forEach((prop) => {
|
|
3064
|
-
if (prop.type ===
|
|
3521
|
+
if (prop.type === import_utils52.AST_NODE_TYPES.Property && prop.value.type === import_utils52.AST_NODE_TYPES.Identifier) {
|
|
3065
3522
|
checkIdentifier(prop.value, declarationNode);
|
|
3066
|
-
} else if (prop.type ===
|
|
3523
|
+
} else if (prop.type === import_utils52.AST_NODE_TYPES.RestElement && prop.argument.type === import_utils52.AST_NODE_TYPES.Identifier) {
|
|
3067
3524
|
checkIdentifier(prop.argument, declarationNode);
|
|
3068
3525
|
}
|
|
3069
3526
|
});
|
|
3070
|
-
} else if (pattern.type ===
|
|
3527
|
+
} else if (pattern.type === import_utils52.AST_NODE_TYPES.ArrayPattern) {
|
|
3071
3528
|
pattern.elements.forEach((element) => {
|
|
3072
|
-
if (element?.type ===
|
|
3529
|
+
if (element?.type === import_utils52.AST_NODE_TYPES.Identifier) {
|
|
3073
3530
|
checkIdentifier(element, declarationNode);
|
|
3074
|
-
} else if (element?.type ===
|
|
3531
|
+
} else if (element?.type === import_utils52.AST_NODE_TYPES.RestElement && element.argument.type === import_utils52.AST_NODE_TYPES.Identifier) {
|
|
3075
3532
|
checkIdentifier(element.argument, declarationNode);
|
|
3076
3533
|
}
|
|
3077
3534
|
});
|
|
3078
|
-
} else if (pattern.type ===
|
|
3535
|
+
} else if (pattern.type === import_utils52.AST_NODE_TYPES.AssignmentPattern && pattern.left.type === import_utils52.AST_NODE_TYPES.Identifier) {
|
|
3079
3536
|
checkIdentifier(pattern.left, declarationNode);
|
|
3080
|
-
} else if (pattern.type ===
|
|
3537
|
+
} else if (pattern.type === import_utils52.AST_NODE_TYPES.RestElement && pattern.argument.type === import_utils52.AST_NODE_TYPES.Identifier) {
|
|
3081
3538
|
checkIdentifier(pattern.argument, declarationNode);
|
|
3082
3539
|
}
|
|
3083
3540
|
};
|
|
@@ -3111,11 +3568,11 @@ var noSingleCharVariables = createRule40({
|
|
|
3111
3568
|
var no_single_char_variables_default = noSingleCharVariables;
|
|
3112
3569
|
|
|
3113
3570
|
// src/rules/prefer-async-await.ts
|
|
3114
|
-
var
|
|
3115
|
-
var
|
|
3571
|
+
var import_utils53 = require("@typescript-eslint/utils");
|
|
3572
|
+
var createRule45 = import_utils53.ESLintUtils.RuleCreator(
|
|
3116
3573
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3117
3574
|
);
|
|
3118
|
-
var preferAsyncAwait =
|
|
3575
|
+
var preferAsyncAwait = createRule45({
|
|
3119
3576
|
name: "prefer-async-await",
|
|
3120
3577
|
meta: {
|
|
3121
3578
|
type: "suggestion",
|
|
@@ -3131,7 +3588,7 @@ var preferAsyncAwait = createRule41({
|
|
|
3131
3588
|
create(context) {
|
|
3132
3589
|
return {
|
|
3133
3590
|
CallExpression(node) {
|
|
3134
|
-
if (node.callee.type ===
|
|
3591
|
+
if (node.callee.type === import_utils53.AST_NODE_TYPES.MemberExpression && node.callee.property.type === import_utils53.AST_NODE_TYPES.Identifier && node.callee.property.name === "then") {
|
|
3135
3592
|
context.report({
|
|
3136
3593
|
node: node.callee.property,
|
|
3137
3594
|
messageId: "preferAsyncAwait"
|
|
@@ -3144,11 +3601,11 @@ var preferAsyncAwait = createRule41({
|
|
|
3144
3601
|
var prefer_async_await_default = preferAsyncAwait;
|
|
3145
3602
|
|
|
3146
3603
|
// src/rules/prefer-destructuring-params.ts
|
|
3147
|
-
var
|
|
3148
|
-
var
|
|
3604
|
+
var import_utils54 = require("@typescript-eslint/utils");
|
|
3605
|
+
var createRule46 = import_utils54.ESLintUtils.RuleCreator(
|
|
3149
3606
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3150
3607
|
);
|
|
3151
|
-
var preferDestructuringParams =
|
|
3608
|
+
var preferDestructuringParams = createRule46({
|
|
3152
3609
|
name: "prefer-destructuring-params",
|
|
3153
3610
|
meta: {
|
|
3154
3611
|
type: "suggestion",
|
|
@@ -3164,18 +3621,18 @@ var preferDestructuringParams = createRule42({
|
|
|
3164
3621
|
create(context) {
|
|
3165
3622
|
const isCallbackFunction2 = (node) => {
|
|
3166
3623
|
const { parent } = node;
|
|
3167
|
-
return parent?.type ===
|
|
3624
|
+
return parent?.type === import_utils54.AST_NODE_TYPES.CallExpression;
|
|
3168
3625
|
};
|
|
3169
3626
|
const isDeveloperFunction = (node) => {
|
|
3170
|
-
if (node.type ===
|
|
3627
|
+
if (node.type === import_utils54.AST_NODE_TYPES.FunctionDeclaration) {
|
|
3171
3628
|
return true;
|
|
3172
3629
|
}
|
|
3173
|
-
if (node.type ===
|
|
3630
|
+
if (node.type === import_utils54.AST_NODE_TYPES.FunctionExpression || node.type === import_utils54.AST_NODE_TYPES.ArrowFunctionExpression) {
|
|
3174
3631
|
if (isCallbackFunction2(node)) {
|
|
3175
3632
|
return false;
|
|
3176
3633
|
}
|
|
3177
3634
|
const { parent } = node;
|
|
3178
|
-
return parent?.type ===
|
|
3635
|
+
return parent?.type === import_utils54.AST_NODE_TYPES.VariableDeclarator || parent?.type === import_utils54.AST_NODE_TYPES.AssignmentExpression || parent?.type === import_utils54.AST_NODE_TYPES.Property || parent?.type === import_utils54.AST_NODE_TYPES.MethodDefinition;
|
|
3179
3636
|
}
|
|
3180
3637
|
return false;
|
|
3181
3638
|
};
|
|
@@ -3187,7 +3644,7 @@ var preferDestructuringParams = createRule42({
|
|
|
3187
3644
|
if (!isDeveloperFunction(node)) {
|
|
3188
3645
|
return;
|
|
3189
3646
|
}
|
|
3190
|
-
if (node.type ===
|
|
3647
|
+
if (node.type === import_utils54.AST_NODE_TYPES.FunctionDeclaration && node.id) {
|
|
3191
3648
|
const functionName = node.id.name;
|
|
3192
3649
|
if (functionName.startsWith("_") || functionName.includes("$") || /^[A-Z][a-zA-Z]*$/.test(functionName)) {
|
|
3193
3650
|
return;
|
|
@@ -3197,7 +3654,7 @@ var preferDestructuringParams = createRule42({
|
|
|
3197
3654
|
return;
|
|
3198
3655
|
}
|
|
3199
3656
|
const hasNonDestructuredParams = node.params.some(
|
|
3200
|
-
(param) => param.type !==
|
|
3657
|
+
(param) => param.type !== import_utils54.AST_NODE_TYPES.ObjectPattern && param.type !== import_utils54.AST_NODE_TYPES.RestElement
|
|
3201
3658
|
);
|
|
3202
3659
|
if (hasNonDestructuredParams) {
|
|
3203
3660
|
context.report({
|
|
@@ -3216,8 +3673,8 @@ var preferDestructuringParams = createRule42({
|
|
|
3216
3673
|
var prefer_destructuring_params_default = preferDestructuringParams;
|
|
3217
3674
|
|
|
3218
3675
|
// src/rules/prefer-function-declaration.ts
|
|
3219
|
-
var
|
|
3220
|
-
var
|
|
3676
|
+
var import_utils55 = require("@typescript-eslint/utils");
|
|
3677
|
+
var createRule47 = import_utils55.ESLintUtils.RuleCreator(
|
|
3221
3678
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3222
3679
|
);
|
|
3223
3680
|
var isTsFile = (filename) => filename.endsWith(".ts") && !filename.endsWith(".d.ts");
|
|
@@ -3226,33 +3683,33 @@ var isCallbackContext = (node) => {
|
|
|
3226
3683
|
if (!parent) {
|
|
3227
3684
|
return false;
|
|
3228
3685
|
}
|
|
3229
|
-
if (parent.type ===
|
|
3686
|
+
if (parent.type === import_utils55.AST_NODE_TYPES.CallExpression && parent.arguments.includes(node)) {
|
|
3230
3687
|
return true;
|
|
3231
3688
|
}
|
|
3232
|
-
if (parent.type ===
|
|
3689
|
+
if (parent.type === import_utils55.AST_NODE_TYPES.NewExpression && parent.arguments.includes(node)) {
|
|
3233
3690
|
return true;
|
|
3234
3691
|
}
|
|
3235
|
-
if (parent.type ===
|
|
3692
|
+
if (parent.type === import_utils55.AST_NODE_TYPES.ReturnStatement) {
|
|
3236
3693
|
return true;
|
|
3237
3694
|
}
|
|
3238
|
-
if (parent.type ===
|
|
3695
|
+
if (parent.type === import_utils55.AST_NODE_TYPES.Property) {
|
|
3239
3696
|
return true;
|
|
3240
3697
|
}
|
|
3241
|
-
if (parent.type ===
|
|
3698
|
+
if (parent.type === import_utils55.AST_NODE_TYPES.ArrayExpression) {
|
|
3242
3699
|
return true;
|
|
3243
3700
|
}
|
|
3244
|
-
if (parent.type ===
|
|
3701
|
+
if (parent.type === import_utils55.AST_NODE_TYPES.ConditionalExpression) {
|
|
3245
3702
|
return true;
|
|
3246
3703
|
}
|
|
3247
|
-
if (parent.type ===
|
|
3704
|
+
if (parent.type === import_utils55.AST_NODE_TYPES.LogicalExpression) {
|
|
3248
3705
|
return true;
|
|
3249
3706
|
}
|
|
3250
|
-
if (parent.type ===
|
|
3707
|
+
if (parent.type === import_utils55.AST_NODE_TYPES.AssignmentExpression && parent.left !== node) {
|
|
3251
3708
|
return true;
|
|
3252
3709
|
}
|
|
3253
3710
|
return false;
|
|
3254
3711
|
};
|
|
3255
|
-
var preferFunctionDeclaration =
|
|
3712
|
+
var preferFunctionDeclaration = createRule47({
|
|
3256
3713
|
name: "prefer-function-declaration",
|
|
3257
3714
|
meta: {
|
|
3258
3715
|
type: "suggestion",
|
|
@@ -3273,14 +3730,14 @@ var preferFunctionDeclaration = createRule43({
|
|
|
3273
3730
|
}
|
|
3274
3731
|
return {
|
|
3275
3732
|
VariableDeclarator(node) {
|
|
3276
|
-
if (node.id.type !==
|
|
3733
|
+
if (node.id.type !== import_utils55.AST_NODE_TYPES.Identifier) {
|
|
3277
3734
|
return;
|
|
3278
3735
|
}
|
|
3279
3736
|
const { init } = node;
|
|
3280
3737
|
if (!init) {
|
|
3281
3738
|
return;
|
|
3282
3739
|
}
|
|
3283
|
-
if (init.type ===
|
|
3740
|
+
if (init.type === import_utils55.AST_NODE_TYPES.ArrowFunctionExpression) {
|
|
3284
3741
|
if (isCallbackContext(init)) {
|
|
3285
3742
|
return;
|
|
3286
3743
|
}
|
|
@@ -3290,7 +3747,7 @@ var preferFunctionDeclaration = createRule43({
|
|
|
3290
3747
|
data: { name: node.id.name }
|
|
3291
3748
|
});
|
|
3292
3749
|
}
|
|
3293
|
-
if (init.type ===
|
|
3750
|
+
if (init.type === import_utils55.AST_NODE_TYPES.FunctionExpression) {
|
|
3294
3751
|
if (isCallbackContext(init)) {
|
|
3295
3752
|
return;
|
|
3296
3753
|
}
|
|
@@ -3307,11 +3764,11 @@ var preferFunctionDeclaration = createRule43({
|
|
|
3307
3764
|
var prefer_function_declaration_default = preferFunctionDeclaration;
|
|
3308
3765
|
|
|
3309
3766
|
// src/rules/prefer-guard-clause.ts
|
|
3310
|
-
var
|
|
3311
|
-
var
|
|
3767
|
+
var import_utils56 = require("@typescript-eslint/utils");
|
|
3768
|
+
var createRule48 = import_utils56.ESLintUtils.RuleCreator(
|
|
3312
3769
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3313
3770
|
);
|
|
3314
|
-
var preferGuardClause =
|
|
3771
|
+
var preferGuardClause = createRule48({
|
|
3315
3772
|
name: "prefer-guard-clause",
|
|
3316
3773
|
meta: {
|
|
3317
3774
|
type: "suggestion",
|
|
@@ -3328,8 +3785,8 @@ var preferGuardClause = createRule44({
|
|
|
3328
3785
|
return {
|
|
3329
3786
|
IfStatement(node) {
|
|
3330
3787
|
const { consequent } = node;
|
|
3331
|
-
if (consequent.type ===
|
|
3332
|
-
const hasNestedIf = consequent.body.some((statement) => statement.type ===
|
|
3788
|
+
if (consequent.type === import_utils56.AST_NODE_TYPES.BlockStatement) {
|
|
3789
|
+
const hasNestedIf = consequent.body.some((statement) => statement.type === import_utils56.AST_NODE_TYPES.IfStatement);
|
|
3333
3790
|
if (hasNestedIf && consequent.body.length === 1) {
|
|
3334
3791
|
context.report({
|
|
3335
3792
|
node,
|
|
@@ -3337,7 +3794,7 @@ var preferGuardClause = createRule44({
|
|
|
3337
3794
|
});
|
|
3338
3795
|
}
|
|
3339
3796
|
}
|
|
3340
|
-
if (consequent.type ===
|
|
3797
|
+
if (consequent.type === import_utils56.AST_NODE_TYPES.IfStatement) {
|
|
3341
3798
|
context.report({
|
|
3342
3799
|
node,
|
|
3343
3800
|
messageId: "preferGuardClause"
|
|
@@ -3350,11 +3807,11 @@ var preferGuardClause = createRule44({
|
|
|
3350
3807
|
var prefer_guard_clause_default = preferGuardClause;
|
|
3351
3808
|
|
|
3352
3809
|
// src/rules/prefer-import-type.ts
|
|
3353
|
-
var
|
|
3354
|
-
var
|
|
3810
|
+
var import_utils57 = require("@typescript-eslint/utils");
|
|
3811
|
+
var createRule49 = import_utils57.ESLintUtils.RuleCreator(
|
|
3355
3812
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3356
3813
|
);
|
|
3357
|
-
var preferImportType =
|
|
3814
|
+
var preferImportType = createRule49({
|
|
3358
3815
|
name: "prefer-import-type",
|
|
3359
3816
|
meta: {
|
|
3360
3817
|
type: "suggestion",
|
|
@@ -3373,22 +3830,22 @@ var preferImportType = createRule45({
|
|
|
3373
3830
|
let current = node;
|
|
3374
3831
|
while (current) {
|
|
3375
3832
|
switch (current.type) {
|
|
3376
|
-
case
|
|
3377
|
-
case
|
|
3378
|
-
case
|
|
3379
|
-
case
|
|
3380
|
-
case
|
|
3381
|
-
case
|
|
3382
|
-
case
|
|
3383
|
-
case
|
|
3384
|
-
case
|
|
3385
|
-
case
|
|
3386
|
-
case
|
|
3387
|
-
case
|
|
3388
|
-
case
|
|
3833
|
+
case import_utils57.AST_NODE_TYPES.TSTypeReference:
|
|
3834
|
+
case import_utils57.AST_NODE_TYPES.TSTypeAnnotation:
|
|
3835
|
+
case import_utils57.AST_NODE_TYPES.TSTypeParameterInstantiation:
|
|
3836
|
+
case import_utils57.AST_NODE_TYPES.TSInterfaceHeritage:
|
|
3837
|
+
case import_utils57.AST_NODE_TYPES.TSClassImplements:
|
|
3838
|
+
case import_utils57.AST_NODE_TYPES.TSTypeQuery:
|
|
3839
|
+
case import_utils57.AST_NODE_TYPES.TSTypeAssertion:
|
|
3840
|
+
case import_utils57.AST_NODE_TYPES.TSAsExpression:
|
|
3841
|
+
case import_utils57.AST_NODE_TYPES.TSSatisfiesExpression:
|
|
3842
|
+
case import_utils57.AST_NODE_TYPES.TSTypeAliasDeclaration:
|
|
3843
|
+
case import_utils57.AST_NODE_TYPES.TSInterfaceDeclaration:
|
|
3844
|
+
case import_utils57.AST_NODE_TYPES.TSTypeParameter:
|
|
3845
|
+
case import_utils57.AST_NODE_TYPES.TSQualifiedName:
|
|
3389
3846
|
return true;
|
|
3390
|
-
case
|
|
3391
|
-
case
|
|
3847
|
+
case import_utils57.AST_NODE_TYPES.MemberExpression:
|
|
3848
|
+
case import_utils57.AST_NODE_TYPES.Identifier:
|
|
3392
3849
|
current = current.parent;
|
|
3393
3850
|
break;
|
|
3394
3851
|
default:
|
|
@@ -3418,27 +3875,27 @@ var preferImportType = createRule45({
|
|
|
3418
3875
|
return false;
|
|
3419
3876
|
}
|
|
3420
3877
|
switch (parent.type) {
|
|
3421
|
-
case
|
|
3422
|
-
case
|
|
3423
|
-
case
|
|
3424
|
-
case
|
|
3425
|
-
case
|
|
3426
|
-
case
|
|
3427
|
-
case
|
|
3428
|
-
case
|
|
3429
|
-
case
|
|
3430
|
-
case
|
|
3431
|
-
case
|
|
3432
|
-
case
|
|
3433
|
-
case
|
|
3434
|
-
case
|
|
3435
|
-
case
|
|
3436
|
-
case
|
|
3437
|
-
case
|
|
3438
|
-
case
|
|
3439
|
-
case
|
|
3440
|
-
case
|
|
3441
|
-
case
|
|
3878
|
+
case import_utils57.AST_NODE_TYPES.CallExpression:
|
|
3879
|
+
case import_utils57.AST_NODE_TYPES.NewExpression:
|
|
3880
|
+
case import_utils57.AST_NODE_TYPES.JSXOpeningElement:
|
|
3881
|
+
case import_utils57.AST_NODE_TYPES.JSXClosingElement:
|
|
3882
|
+
case import_utils57.AST_NODE_TYPES.MemberExpression:
|
|
3883
|
+
case import_utils57.AST_NODE_TYPES.VariableDeclarator:
|
|
3884
|
+
case import_utils57.AST_NODE_TYPES.TaggedTemplateExpression:
|
|
3885
|
+
case import_utils57.AST_NODE_TYPES.SpreadElement:
|
|
3886
|
+
case import_utils57.AST_NODE_TYPES.ExportSpecifier:
|
|
3887
|
+
case import_utils57.AST_NODE_TYPES.ArrayExpression:
|
|
3888
|
+
case import_utils57.AST_NODE_TYPES.ObjectExpression:
|
|
3889
|
+
case import_utils57.AST_NODE_TYPES.BinaryExpression:
|
|
3890
|
+
case import_utils57.AST_NODE_TYPES.LogicalExpression:
|
|
3891
|
+
case import_utils57.AST_NODE_TYPES.UnaryExpression:
|
|
3892
|
+
case import_utils57.AST_NODE_TYPES.ReturnStatement:
|
|
3893
|
+
case import_utils57.AST_NODE_TYPES.ArrowFunctionExpression:
|
|
3894
|
+
case import_utils57.AST_NODE_TYPES.ConditionalExpression:
|
|
3895
|
+
case import_utils57.AST_NODE_TYPES.AwaitExpression:
|
|
3896
|
+
case import_utils57.AST_NODE_TYPES.YieldExpression:
|
|
3897
|
+
case import_utils57.AST_NODE_TYPES.Property:
|
|
3898
|
+
case import_utils57.AST_NODE_TYPES.JSXExpressionContainer:
|
|
3442
3899
|
return true;
|
|
3443
3900
|
default:
|
|
3444
3901
|
return false;
|
|
@@ -3450,7 +3907,7 @@ var preferImportType = createRule45({
|
|
|
3450
3907
|
return;
|
|
3451
3908
|
}
|
|
3452
3909
|
const hasInlineTypeSpecifier = node.specifiers.some(
|
|
3453
|
-
(specifier) => specifier.type ===
|
|
3910
|
+
(specifier) => specifier.type === import_utils57.AST_NODE_TYPES.ImportSpecifier && specifier.importKind === "type"
|
|
3454
3911
|
);
|
|
3455
3912
|
if (hasInlineTypeSpecifier) {
|
|
3456
3913
|
return;
|
|
@@ -3468,13 +3925,13 @@ var preferImportType = createRule45({
|
|
|
3468
3925
|
}
|
|
3469
3926
|
const scope = context.sourceCode.getScope(node);
|
|
3470
3927
|
const isTypeOnlyImport2 = node.specifiers.every((specifier) => {
|
|
3471
|
-
if (specifier.type ===
|
|
3928
|
+
if (specifier.type === import_utils57.AST_NODE_TYPES.ImportDefaultSpecifier) {
|
|
3472
3929
|
return false;
|
|
3473
3930
|
}
|
|
3474
|
-
if (specifier.type ===
|
|
3931
|
+
if (specifier.type === import_utils57.AST_NODE_TYPES.ImportNamespaceSpecifier) {
|
|
3475
3932
|
return false;
|
|
3476
3933
|
}
|
|
3477
|
-
if (specifier.type ===
|
|
3934
|
+
if (specifier.type === import_utils57.AST_NODE_TYPES.ImportSpecifier) {
|
|
3478
3935
|
const localName = specifier.local.name;
|
|
3479
3936
|
return !isUsedAsValue(localName, scope);
|
|
3480
3937
|
}
|
|
@@ -3500,19 +3957,19 @@ var preferImportType = createRule45({
|
|
|
3500
3957
|
var prefer_import_type_default = preferImportType;
|
|
3501
3958
|
|
|
3502
3959
|
// src/rules/prefer-inline-literal-union.ts
|
|
3503
|
-
var
|
|
3504
|
-
var
|
|
3960
|
+
var import_utils58 = require("@typescript-eslint/utils");
|
|
3961
|
+
var createRule50 = import_utils58.ESLintUtils.RuleCreator(
|
|
3505
3962
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3506
3963
|
);
|
|
3507
3964
|
function isLiteralUnionType(node) {
|
|
3508
|
-
if (node.type !==
|
|
3965
|
+
if (node.type !== import_utils58.AST_NODE_TYPES.TSUnionType) {
|
|
3509
3966
|
return false;
|
|
3510
3967
|
}
|
|
3511
3968
|
return node.types.every(
|
|
3512
|
-
(member) => member.type ===
|
|
3969
|
+
(member) => member.type === import_utils58.AST_NODE_TYPES.TSLiteralType || member.type === import_utils58.AST_NODE_TYPES.TSNullKeyword || member.type === import_utils58.AST_NODE_TYPES.TSUndefinedKeyword
|
|
3513
3970
|
);
|
|
3514
3971
|
}
|
|
3515
|
-
var preferInlineLiteralUnion =
|
|
3972
|
+
var preferInlineLiteralUnion = createRule50({
|
|
3516
3973
|
name: "prefer-inline-literal-union",
|
|
3517
3974
|
meta: {
|
|
3518
3975
|
type: "suggestion",
|
|
@@ -3539,10 +3996,10 @@ var preferInlineLiteralUnion = createRule46({
|
|
|
3539
3996
|
return;
|
|
3540
3997
|
}
|
|
3541
3998
|
const { typeAnnotation } = node.typeAnnotation;
|
|
3542
|
-
if (typeAnnotation.type !==
|
|
3999
|
+
if (typeAnnotation.type !== import_utils58.AST_NODE_TYPES.TSTypeReference) {
|
|
3543
4000
|
return;
|
|
3544
4001
|
}
|
|
3545
|
-
if (typeAnnotation.typeName.type !==
|
|
4002
|
+
if (typeAnnotation.typeName.type !== import_utils58.AST_NODE_TYPES.Identifier) {
|
|
3546
4003
|
return;
|
|
3547
4004
|
}
|
|
3548
4005
|
const aliasName = typeAnnotation.typeName.name;
|
|
@@ -3566,12 +4023,12 @@ var preferInlineLiteralUnion = createRule46({
|
|
|
3566
4023
|
var prefer_inline_literal_union_default = preferInlineLiteralUnion;
|
|
3567
4024
|
|
|
3568
4025
|
// src/rules/prefer-inline-type-export.ts
|
|
3569
|
-
var
|
|
3570
|
-
var
|
|
4026
|
+
var import_utils59 = require("@typescript-eslint/utils");
|
|
4027
|
+
var createRule51 = import_utils59.ESLintUtils.RuleCreator(
|
|
3571
4028
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3572
4029
|
);
|
|
3573
|
-
var isTypeDeclaration = (node) => node.type ===
|
|
3574
|
-
var preferInlineTypeExport =
|
|
4030
|
+
var isTypeDeclaration = (node) => node.type === import_utils59.AST_NODE_TYPES.TSInterfaceDeclaration || node.type === import_utils59.AST_NODE_TYPES.TSTypeAliasDeclaration;
|
|
4031
|
+
var preferInlineTypeExport = createRule51({
|
|
3575
4032
|
name: "prefer-inline-type-export",
|
|
3576
4033
|
meta: {
|
|
3577
4034
|
type: "suggestion",
|
|
@@ -3588,12 +4045,12 @@ var preferInlineTypeExport = createRule47({
|
|
|
3588
4045
|
create(context) {
|
|
3589
4046
|
const typeDeclarations = /* @__PURE__ */ new Map();
|
|
3590
4047
|
function collectDeclaration(node) {
|
|
3591
|
-
if (node.parent.type !==
|
|
4048
|
+
if (node.parent.type !== import_utils59.AST_NODE_TYPES.ExportNamedDeclaration) {
|
|
3592
4049
|
typeDeclarations.set(node.id.name, node);
|
|
3593
4050
|
}
|
|
3594
4051
|
}
|
|
3595
4052
|
function reportSpecifier(specifier, statement, declarationNode) {
|
|
3596
|
-
if (specifier.local.type !==
|
|
4053
|
+
if (specifier.local.type !== import_utils59.AST_NODE_TYPES.Identifier) {
|
|
3597
4054
|
return;
|
|
3598
4055
|
}
|
|
3599
4056
|
const { name } = specifier.local;
|
|
@@ -3626,16 +4083,16 @@ var preferInlineTypeExport = createRule47({
|
|
|
3626
4083
|
return {
|
|
3627
4084
|
Program(node) {
|
|
3628
4085
|
node.body.forEach((statement) => {
|
|
3629
|
-
if (statement.type ===
|
|
4086
|
+
if (statement.type === import_utils59.AST_NODE_TYPES.TSInterfaceDeclaration || statement.type === import_utils59.AST_NODE_TYPES.TSTypeAliasDeclaration) {
|
|
3630
4087
|
collectDeclaration(statement);
|
|
3631
4088
|
}
|
|
3632
4089
|
});
|
|
3633
4090
|
node.body.forEach((statement) => {
|
|
3634
|
-
if (statement.type !==
|
|
4091
|
+
if (statement.type !== import_utils59.AST_NODE_TYPES.ExportNamedDeclaration || statement.declaration !== null) {
|
|
3635
4092
|
return;
|
|
3636
4093
|
}
|
|
3637
4094
|
statement.specifiers.forEach((specifier) => {
|
|
3638
|
-
if (specifier.local.type !==
|
|
4095
|
+
if (specifier.local.type !== import_utils59.AST_NODE_TYPES.Identifier) {
|
|
3639
4096
|
return;
|
|
3640
4097
|
}
|
|
3641
4098
|
const declarationNode = typeDeclarations.get(specifier.local.name);
|
|
@@ -3652,11 +4109,11 @@ var preferInlineTypeExport = createRule47({
|
|
|
3652
4109
|
var prefer_inline_type_export_default = preferInlineTypeExport;
|
|
3653
4110
|
|
|
3654
4111
|
// src/rules/prefer-interface-for-component-props.ts
|
|
3655
|
-
var
|
|
3656
|
-
var
|
|
4112
|
+
var import_utils60 = require("@typescript-eslint/utils");
|
|
4113
|
+
var createRule52 = import_utils60.ESLintUtils.RuleCreator(
|
|
3657
4114
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3658
4115
|
);
|
|
3659
|
-
var preferInterfaceForComponentProps =
|
|
4116
|
+
var preferInterfaceForComponentProps = createRule52({
|
|
3660
4117
|
name: "prefer-interface-for-component-props",
|
|
3661
4118
|
meta: {
|
|
3662
4119
|
type: "suggestion",
|
|
@@ -3676,13 +4133,13 @@ var preferInterfaceForComponentProps = createRule48({
|
|
|
3676
4133
|
}
|
|
3677
4134
|
return {
|
|
3678
4135
|
TSTypeAliasDeclaration(node) {
|
|
3679
|
-
if (node.id.type !==
|
|
4136
|
+
if (node.id.type !== import_utils60.AST_NODE_TYPES.Identifier) {
|
|
3680
4137
|
return;
|
|
3681
4138
|
}
|
|
3682
4139
|
if (!node.id.name.endsWith("Props")) {
|
|
3683
4140
|
return;
|
|
3684
4141
|
}
|
|
3685
|
-
if (node.typeAnnotation.type !==
|
|
4142
|
+
if (node.typeAnnotation.type !== import_utils60.AST_NODE_TYPES.TSTypeLiteral) {
|
|
3686
4143
|
return;
|
|
3687
4144
|
}
|
|
3688
4145
|
const { name } = node.id;
|
|
@@ -3709,11 +4166,11 @@ var preferInterfaceForComponentProps = createRule48({
|
|
|
3709
4166
|
var prefer_interface_for_component_props_default = preferInterfaceForComponentProps;
|
|
3710
4167
|
|
|
3711
4168
|
// src/rules/prefer-interface-over-inline-types.ts
|
|
3712
|
-
var
|
|
3713
|
-
var
|
|
4169
|
+
var import_utils62 = require("@typescript-eslint/utils");
|
|
4170
|
+
var createRule53 = import_utils62.ESLintUtils.RuleCreator(
|
|
3714
4171
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3715
4172
|
);
|
|
3716
|
-
var preferInterfaceOverInlineTypes =
|
|
4173
|
+
var preferInterfaceOverInlineTypes = createRule53({
|
|
3717
4174
|
name: "prefer-interface-over-inline-types",
|
|
3718
4175
|
meta: {
|
|
3719
4176
|
type: "suggestion",
|
|
@@ -3729,54 +4186,54 @@ var preferInterfaceOverInlineTypes = createRule49({
|
|
|
3729
4186
|
defaultOptions: [],
|
|
3730
4187
|
create(context) {
|
|
3731
4188
|
function hasJSXInConditional(node) {
|
|
3732
|
-
return node.consequent.type ===
|
|
4189
|
+
return node.consequent.type === import_utils62.AST_NODE_TYPES.JSXElement || node.consequent.type === import_utils62.AST_NODE_TYPES.JSXFragment || node.alternate.type === import_utils62.AST_NODE_TYPES.JSXElement || node.alternate.type === import_utils62.AST_NODE_TYPES.JSXFragment;
|
|
3733
4190
|
}
|
|
3734
4191
|
function hasJSXInLogical(node) {
|
|
3735
|
-
return node.right.type ===
|
|
4192
|
+
return node.right.type === import_utils62.AST_NODE_TYPES.JSXElement || node.right.type === import_utils62.AST_NODE_TYPES.JSXFragment;
|
|
3736
4193
|
}
|
|
3737
4194
|
function hasJSXReturn(block) {
|
|
3738
4195
|
return block.body.some((stmt) => {
|
|
3739
|
-
if (stmt.type ===
|
|
3740
|
-
return stmt.argument.type ===
|
|
4196
|
+
if (stmt.type === import_utils62.AST_NODE_TYPES.ReturnStatement && stmt.argument) {
|
|
4197
|
+
return stmt.argument.type === import_utils62.AST_NODE_TYPES.JSXElement || stmt.argument.type === import_utils62.AST_NODE_TYPES.JSXFragment || stmt.argument.type === import_utils62.AST_NODE_TYPES.ConditionalExpression && hasJSXInConditional(stmt.argument) || stmt.argument.type === import_utils62.AST_NODE_TYPES.LogicalExpression && hasJSXInLogical(stmt.argument);
|
|
3741
4198
|
}
|
|
3742
4199
|
return false;
|
|
3743
4200
|
});
|
|
3744
4201
|
}
|
|
3745
4202
|
function isReactComponent2(node) {
|
|
3746
|
-
if (node.type ===
|
|
3747
|
-
if (node.body.type ===
|
|
4203
|
+
if (node.type === import_utils62.AST_NODE_TYPES.ArrowFunctionExpression) {
|
|
4204
|
+
if (node.body.type === import_utils62.AST_NODE_TYPES.JSXElement || node.body.type === import_utils62.AST_NODE_TYPES.JSXFragment) {
|
|
3748
4205
|
return true;
|
|
3749
4206
|
}
|
|
3750
|
-
if (node.body.type ===
|
|
4207
|
+
if (node.body.type === import_utils62.AST_NODE_TYPES.BlockStatement) {
|
|
3751
4208
|
return hasJSXReturn(node.body);
|
|
3752
4209
|
}
|
|
3753
|
-
} else if (node.type ===
|
|
3754
|
-
if (node.body && node.body.type ===
|
|
4210
|
+
} else if (node.type === import_utils62.AST_NODE_TYPES.FunctionExpression || node.type === import_utils62.AST_NODE_TYPES.FunctionDeclaration) {
|
|
4211
|
+
if (node.body && node.body.type === import_utils62.AST_NODE_TYPES.BlockStatement) {
|
|
3755
4212
|
return hasJSXReturn(node.body);
|
|
3756
4213
|
}
|
|
3757
4214
|
}
|
|
3758
4215
|
return false;
|
|
3759
4216
|
}
|
|
3760
4217
|
function isInlineTypeAnnotation(node) {
|
|
3761
|
-
if (node.type ===
|
|
4218
|
+
if (node.type === import_utils62.AST_NODE_TYPES.TSTypeLiteral) {
|
|
3762
4219
|
return true;
|
|
3763
4220
|
}
|
|
3764
|
-
if (node.type ===
|
|
3765
|
-
return node.typeArguments.params.some((param) => param.type ===
|
|
4221
|
+
if (node.type === import_utils62.AST_NODE_TYPES.TSTypeReference && node.typeArguments) {
|
|
4222
|
+
return node.typeArguments.params.some((param) => param.type === import_utils62.AST_NODE_TYPES.TSTypeLiteral);
|
|
3766
4223
|
}
|
|
3767
|
-
if (node.type ===
|
|
4224
|
+
if (node.type === import_utils62.AST_NODE_TYPES.TSUnionType) {
|
|
3768
4225
|
return node.types.some((type) => isInlineTypeAnnotation(type));
|
|
3769
4226
|
}
|
|
3770
4227
|
return false;
|
|
3771
4228
|
}
|
|
3772
4229
|
function hasInlineObjectType(node) {
|
|
3773
|
-
if (node.type ===
|
|
4230
|
+
if (node.type === import_utils62.AST_NODE_TYPES.TSTypeLiteral) {
|
|
3774
4231
|
return true;
|
|
3775
4232
|
}
|
|
3776
|
-
if (node.type ===
|
|
3777
|
-
return node.typeArguments.params.some((param) => param.type ===
|
|
4233
|
+
if (node.type === import_utils62.AST_NODE_TYPES.TSTypeReference && node.typeArguments) {
|
|
4234
|
+
return node.typeArguments.params.some((param) => param.type === import_utils62.AST_NODE_TYPES.TSTypeLiteral);
|
|
3778
4235
|
}
|
|
3779
|
-
if (node.type ===
|
|
4236
|
+
if (node.type === import_utils62.AST_NODE_TYPES.TSUnionType) {
|
|
3780
4237
|
return node.types.some((type) => hasInlineObjectType(type));
|
|
3781
4238
|
}
|
|
3782
4239
|
return false;
|
|
@@ -3789,7 +4246,7 @@ var preferInterfaceOverInlineTypes = createRule49({
|
|
|
3789
4246
|
return;
|
|
3790
4247
|
}
|
|
3791
4248
|
const param = node.params[0];
|
|
3792
|
-
if (param.type ===
|
|
4249
|
+
if (param.type === import_utils62.AST_NODE_TYPES.Identifier && param.typeAnnotation) {
|
|
3793
4250
|
const { typeAnnotation } = param.typeAnnotation;
|
|
3794
4251
|
if (isInlineTypeAnnotation(typeAnnotation) && hasInlineObjectType(typeAnnotation)) {
|
|
3795
4252
|
context.report({
|
|
@@ -3809,11 +4266,11 @@ var preferInterfaceOverInlineTypes = createRule49({
|
|
|
3809
4266
|
var prefer_interface_over_inline_types_default = preferInterfaceOverInlineTypes;
|
|
3810
4267
|
|
|
3811
4268
|
// src/rules/prefer-jsx-template-literals.ts
|
|
3812
|
-
var
|
|
3813
|
-
var
|
|
4269
|
+
var import_utils63 = require("@typescript-eslint/utils");
|
|
4270
|
+
var createRule54 = import_utils63.ESLintUtils.RuleCreator(
|
|
3814
4271
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3815
4272
|
);
|
|
3816
|
-
var preferJSXTemplateLiterals =
|
|
4273
|
+
var preferJSXTemplateLiterals = createRule54({
|
|
3817
4274
|
name: "prefer-jsx-template-literals",
|
|
3818
4275
|
meta: {
|
|
3819
4276
|
type: "suggestion",
|
|
@@ -3882,9 +4339,9 @@ var preferJSXTemplateLiterals = createRule50({
|
|
|
3882
4339
|
if (!child || !nextChild) {
|
|
3883
4340
|
return;
|
|
3884
4341
|
}
|
|
3885
|
-
if (child.type ===
|
|
4342
|
+
if (child.type === import_utils63.AST_NODE_TYPES.JSXText && nextChild.type === import_utils63.AST_NODE_TYPES.JSXExpressionContainer) {
|
|
3886
4343
|
handleTextBeforeExpression(child, nextChild);
|
|
3887
|
-
} else if (child.type ===
|
|
4344
|
+
} else if (child.type === import_utils63.AST_NODE_TYPES.JSXExpressionContainer && nextChild.type === import_utils63.AST_NODE_TYPES.JSXText) {
|
|
3888
4345
|
handleExpressionBeforeText(child, nextChild);
|
|
3889
4346
|
}
|
|
3890
4347
|
}
|
|
@@ -3897,32 +4354,32 @@ var preferJSXTemplateLiterals = createRule50({
|
|
|
3897
4354
|
var prefer_jsx_template_literals_default = preferJSXTemplateLiterals;
|
|
3898
4355
|
|
|
3899
4356
|
// src/rules/prefer-named-param-types.ts
|
|
3900
|
-
var
|
|
3901
|
-
var
|
|
4357
|
+
var import_utils64 = require("@typescript-eslint/utils");
|
|
4358
|
+
var createRule55 = import_utils64.ESLintUtils.RuleCreator(
|
|
3902
4359
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3903
4360
|
);
|
|
3904
4361
|
var returnsJsx2 = (node) => {
|
|
3905
|
-
if (node.type ===
|
|
4362
|
+
if (node.type === import_utils64.AST_NODE_TYPES.JSXElement || node.type === import_utils64.AST_NODE_TYPES.JSXFragment) {
|
|
3906
4363
|
return true;
|
|
3907
4364
|
}
|
|
3908
|
-
if (node.type ===
|
|
4365
|
+
if (node.type === import_utils64.AST_NODE_TYPES.ConditionalExpression) {
|
|
3909
4366
|
return returnsJsx2(node.consequent) || returnsJsx2(node.alternate);
|
|
3910
4367
|
}
|
|
3911
|
-
if (node.type ===
|
|
4368
|
+
if (node.type === import_utils64.AST_NODE_TYPES.LogicalExpression) {
|
|
3912
4369
|
return returnsJsx2(node.left) || returnsJsx2(node.right);
|
|
3913
4370
|
}
|
|
3914
4371
|
return false;
|
|
3915
4372
|
};
|
|
3916
4373
|
var bodyReturnsJsx2 = (body) => {
|
|
3917
|
-
if (body.type !==
|
|
4374
|
+
if (body.type !== import_utils64.AST_NODE_TYPES.BlockStatement) {
|
|
3918
4375
|
return returnsJsx2(body);
|
|
3919
4376
|
}
|
|
3920
4377
|
return body.body.some(
|
|
3921
|
-
(stmt) => stmt.type ===
|
|
4378
|
+
(stmt) => stmt.type === import_utils64.AST_NODE_TYPES.ReturnStatement && stmt.argument !== null && returnsJsx2(stmt.argument)
|
|
3922
4379
|
);
|
|
3923
4380
|
};
|
|
3924
4381
|
var isReactComponentFunction = (node) => bodyReturnsJsx2(node.body);
|
|
3925
|
-
var preferNamedParamTypes =
|
|
4382
|
+
var preferNamedParamTypes = createRule55({
|
|
3926
4383
|
name: "prefer-named-param-types",
|
|
3927
4384
|
meta: {
|
|
3928
4385
|
type: "suggestion",
|
|
@@ -3937,16 +4394,16 @@ var preferNamedParamTypes = createRule51({
|
|
|
3937
4394
|
defaultOptions: [],
|
|
3938
4395
|
create(context) {
|
|
3939
4396
|
function hasInlineObjectType(param) {
|
|
3940
|
-
if (param.type ===
|
|
4397
|
+
if (param.type === import_utils64.AST_NODE_TYPES.AssignmentPattern) {
|
|
3941
4398
|
return hasInlineObjectType(param.left);
|
|
3942
4399
|
}
|
|
3943
|
-
if (param.type ===
|
|
3944
|
-
if (param.typeAnnotation?.typeAnnotation.type ===
|
|
4400
|
+
if (param.type === import_utils64.AST_NODE_TYPES.ObjectPattern) {
|
|
4401
|
+
if (param.typeAnnotation?.typeAnnotation.type === import_utils64.AST_NODE_TYPES.TSTypeLiteral) {
|
|
3945
4402
|
return true;
|
|
3946
4403
|
}
|
|
3947
4404
|
}
|
|
3948
|
-
if (param.type ===
|
|
3949
|
-
if (param.typeAnnotation?.typeAnnotation.type ===
|
|
4405
|
+
if (param.type === import_utils64.AST_NODE_TYPES.Identifier) {
|
|
4406
|
+
if (param.typeAnnotation?.typeAnnotation.type === import_utils64.AST_NODE_TYPES.TSTypeLiteral) {
|
|
3950
4407
|
return true;
|
|
3951
4408
|
}
|
|
3952
4409
|
}
|
|
@@ -3959,7 +4416,7 @@ var preferNamedParamTypes = createRule51({
|
|
|
3959
4416
|
} else if ("value" in node && node.value) {
|
|
3960
4417
|
params = node.value.params;
|
|
3961
4418
|
}
|
|
3962
|
-
if ((node.type ===
|
|
4419
|
+
if ((node.type === import_utils64.AST_NODE_TYPES.FunctionDeclaration || node.type === import_utils64.AST_NODE_TYPES.FunctionExpression || node.type === import_utils64.AST_NODE_TYPES.ArrowFunctionExpression) && params.length === 1 && params[0].type === import_utils64.AST_NODE_TYPES.Identifier && isReactComponentFunction(node)) {
|
|
3963
4420
|
return;
|
|
3964
4421
|
}
|
|
3965
4422
|
params.forEach((param) => {
|
|
@@ -3983,11 +4440,11 @@ var preferNamedParamTypes = createRule51({
|
|
|
3983
4440
|
var prefer_named_param_types_default = preferNamedParamTypes;
|
|
3984
4441
|
|
|
3985
4442
|
// src/rules/prefer-props-with-children.ts
|
|
3986
|
-
var
|
|
3987
|
-
var
|
|
4443
|
+
var import_utils65 = require("@typescript-eslint/utils");
|
|
4444
|
+
var createRule56 = import_utils65.ESLintUtils.RuleCreator(
|
|
3988
4445
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3989
4446
|
);
|
|
3990
|
-
var preferPropsWithChildren =
|
|
4447
|
+
var preferPropsWithChildren = createRule56({
|
|
3991
4448
|
name: "prefer-props-with-children",
|
|
3992
4449
|
meta: {
|
|
3993
4450
|
type: "suggestion",
|
|
@@ -4005,24 +4462,24 @@ var preferPropsWithChildren = createRule52({
|
|
|
4005
4462
|
if (!typeNode) {
|
|
4006
4463
|
return false;
|
|
4007
4464
|
}
|
|
4008
|
-
if (typeNode.type !==
|
|
4465
|
+
if (typeNode.type !== import_utils65.AST_NODE_TYPES.TSTypeReference) {
|
|
4009
4466
|
return false;
|
|
4010
4467
|
}
|
|
4011
4468
|
const { typeName } = typeNode;
|
|
4012
|
-
if (typeName.type ===
|
|
4469
|
+
if (typeName.type === import_utils65.AST_NODE_TYPES.Identifier) {
|
|
4013
4470
|
return typeName.name === "ReactNode";
|
|
4014
4471
|
}
|
|
4015
|
-
if (typeName.type ===
|
|
4472
|
+
if (typeName.type === import_utils65.AST_NODE_TYPES.TSQualifiedName && typeName.left.type === import_utils65.AST_NODE_TYPES.Identifier && typeName.left.name === "React" && typeName.right.type === import_utils65.AST_NODE_TYPES.Identifier && typeName.right.name === "ReactNode") {
|
|
4016
4473
|
return true;
|
|
4017
4474
|
}
|
|
4018
4475
|
return false;
|
|
4019
4476
|
}
|
|
4020
4477
|
function findChildrenReactNode(members) {
|
|
4021
4478
|
for (const member of members) {
|
|
4022
|
-
if (member.type !==
|
|
4479
|
+
if (member.type !== import_utils65.AST_NODE_TYPES.TSPropertySignature) {
|
|
4023
4480
|
continue;
|
|
4024
4481
|
}
|
|
4025
|
-
if (member.key.type !==
|
|
4482
|
+
if (member.key.type !== import_utils65.AST_NODE_TYPES.Identifier) {
|
|
4026
4483
|
continue;
|
|
4027
4484
|
}
|
|
4028
4485
|
if (member.key.name !== "children") {
|
|
@@ -4062,11 +4519,11 @@ var preferPropsWithChildren = createRule52({
|
|
|
4062
4519
|
var prefer_props_with_children_default = preferPropsWithChildren;
|
|
4063
4520
|
|
|
4064
4521
|
// src/rules/prefer-react-import-types.ts
|
|
4065
|
-
var
|
|
4066
|
-
var
|
|
4522
|
+
var import_utils66 = require("@typescript-eslint/utils");
|
|
4523
|
+
var createRule57 = import_utils66.ESLintUtils.RuleCreator(
|
|
4067
4524
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
4068
4525
|
);
|
|
4069
|
-
var preferReactImportTypes =
|
|
4526
|
+
var preferReactImportTypes = createRule57({
|
|
4070
4527
|
name: "prefer-react-import-types",
|
|
4071
4528
|
meta: {
|
|
4072
4529
|
type: "suggestion",
|
|
@@ -4142,7 +4599,7 @@ var preferReactImportTypes = createRule53({
|
|
|
4142
4599
|
]);
|
|
4143
4600
|
const allReactExports = /* @__PURE__ */ new Set([...reactTypes, ...reactRuntimeExports]);
|
|
4144
4601
|
function checkMemberExpression(node) {
|
|
4145
|
-
if (node.object.type ===
|
|
4602
|
+
if (node.object.type === import_utils66.AST_NODE_TYPES.Identifier && node.object.name === "React" && node.property.type === import_utils66.AST_NODE_TYPES.Identifier && allReactExports.has(node.property.name)) {
|
|
4146
4603
|
const typeName = node.property.name;
|
|
4147
4604
|
const isType = reactTypes.has(typeName);
|
|
4148
4605
|
const importStatement = isType ? `import type { ${typeName} } from "react"` : `import { ${typeName} } from "react"`;
|
|
@@ -4159,7 +4616,7 @@ var preferReactImportTypes = createRule53({
|
|
|
4159
4616
|
return {
|
|
4160
4617
|
MemberExpression: checkMemberExpression,
|
|
4161
4618
|
"TSTypeReference > TSQualifiedName": (node) => {
|
|
4162
|
-
if (node.left.type ===
|
|
4619
|
+
if (node.left.type === import_utils66.AST_NODE_TYPES.Identifier && node.left.name === "React" && node.right.type === import_utils66.AST_NODE_TYPES.Identifier && allReactExports.has(node.right.name)) {
|
|
4163
4620
|
const typeName = node.right.name;
|
|
4164
4621
|
const isType = reactTypes.has(typeName);
|
|
4165
4622
|
const importStatement = isType ? `import type { ${typeName} } from "react"` : `import { ${typeName} } from "react"`;
|
|
@@ -4179,11 +4636,11 @@ var preferReactImportTypes = createRule53({
|
|
|
4179
4636
|
var prefer_react_import_types_default = preferReactImportTypes;
|
|
4180
4637
|
|
|
4181
4638
|
// src/rules/react-props-destructure.ts
|
|
4182
|
-
var
|
|
4183
|
-
var
|
|
4639
|
+
var import_utils67 = require("@typescript-eslint/utils");
|
|
4640
|
+
var createRule58 = import_utils67.ESLintUtils.RuleCreator(
|
|
4184
4641
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
4185
4642
|
);
|
|
4186
|
-
var reactPropsDestructure =
|
|
4643
|
+
var reactPropsDestructure = createRule58({
|
|
4187
4644
|
name: "react-props-destructure",
|
|
4188
4645
|
meta: {
|
|
4189
4646
|
type: "suggestion",
|
|
@@ -4199,29 +4656,29 @@ var reactPropsDestructure = createRule54({
|
|
|
4199
4656
|
defaultOptions: [],
|
|
4200
4657
|
create(context) {
|
|
4201
4658
|
function hasJSXInConditional(node) {
|
|
4202
|
-
return node.consequent.type ===
|
|
4659
|
+
return node.consequent.type === import_utils67.AST_NODE_TYPES.JSXElement || node.consequent.type === import_utils67.AST_NODE_TYPES.JSXFragment || node.alternate.type === import_utils67.AST_NODE_TYPES.JSXElement || node.alternate.type === import_utils67.AST_NODE_TYPES.JSXFragment;
|
|
4203
4660
|
}
|
|
4204
4661
|
function hasJSXInLogical(node) {
|
|
4205
|
-
return node.right.type ===
|
|
4662
|
+
return node.right.type === import_utils67.AST_NODE_TYPES.JSXElement || node.right.type === import_utils67.AST_NODE_TYPES.JSXFragment;
|
|
4206
4663
|
}
|
|
4207
4664
|
function hasJSXReturn(block) {
|
|
4208
4665
|
return block.body.some((stmt) => {
|
|
4209
|
-
if (stmt.type ===
|
|
4210
|
-
return stmt.argument.type ===
|
|
4666
|
+
if (stmt.type === import_utils67.AST_NODE_TYPES.ReturnStatement && stmt.argument) {
|
|
4667
|
+
return stmt.argument.type === import_utils67.AST_NODE_TYPES.JSXElement || stmt.argument.type === import_utils67.AST_NODE_TYPES.JSXFragment || stmt.argument.type === import_utils67.AST_NODE_TYPES.ConditionalExpression && hasJSXInConditional(stmt.argument) || stmt.argument.type === import_utils67.AST_NODE_TYPES.LogicalExpression && hasJSXInLogical(stmt.argument);
|
|
4211
4668
|
}
|
|
4212
4669
|
return false;
|
|
4213
4670
|
});
|
|
4214
4671
|
}
|
|
4215
4672
|
function isReactComponent2(node) {
|
|
4216
|
-
if (node.type ===
|
|
4217
|
-
if (node.body.type ===
|
|
4673
|
+
if (node.type === import_utils67.AST_NODE_TYPES.ArrowFunctionExpression) {
|
|
4674
|
+
if (node.body.type === import_utils67.AST_NODE_TYPES.JSXElement || node.body.type === import_utils67.AST_NODE_TYPES.JSXFragment) {
|
|
4218
4675
|
return true;
|
|
4219
4676
|
}
|
|
4220
|
-
if (node.body.type ===
|
|
4677
|
+
if (node.body.type === import_utils67.AST_NODE_TYPES.BlockStatement) {
|
|
4221
4678
|
return hasJSXReturn(node.body);
|
|
4222
4679
|
}
|
|
4223
|
-
} else if (node.type ===
|
|
4224
|
-
if (node.body && node.body.type ===
|
|
4680
|
+
} else if (node.type === import_utils67.AST_NODE_TYPES.FunctionExpression || node.type === import_utils67.AST_NODE_TYPES.FunctionDeclaration) {
|
|
4681
|
+
if (node.body && node.body.type === import_utils67.AST_NODE_TYPES.BlockStatement) {
|
|
4225
4682
|
return hasJSXReturn(node.body);
|
|
4226
4683
|
}
|
|
4227
4684
|
}
|
|
@@ -4235,9 +4692,9 @@ var reactPropsDestructure = createRule54({
|
|
|
4235
4692
|
return;
|
|
4236
4693
|
}
|
|
4237
4694
|
const param = node.params[0];
|
|
4238
|
-
if (param.type ===
|
|
4239
|
-
const properties = param.properties.filter((prop) => prop.type ===
|
|
4240
|
-
if (prop.key.type ===
|
|
4695
|
+
if (param.type === import_utils67.AST_NODE_TYPES.ObjectPattern) {
|
|
4696
|
+
const properties = param.properties.filter((prop) => prop.type === import_utils67.AST_NODE_TYPES.Property).map((prop) => {
|
|
4697
|
+
if (prop.key.type === import_utils67.AST_NODE_TYPES.Identifier) {
|
|
4241
4698
|
return prop.key.name;
|
|
4242
4699
|
}
|
|
4243
4700
|
return null;
|
|
@@ -4264,57 +4721,57 @@ var reactPropsDestructure = createRule54({
|
|
|
4264
4721
|
var react_props_destructure_default = reactPropsDestructure;
|
|
4265
4722
|
|
|
4266
4723
|
// src/rules/require-explicit-return-type.ts
|
|
4267
|
-
var
|
|
4268
|
-
var
|
|
4724
|
+
var import_utils68 = require("@typescript-eslint/utils");
|
|
4725
|
+
var createRule59 = import_utils68.ESLintUtils.RuleCreator(
|
|
4269
4726
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
4270
4727
|
);
|
|
4271
4728
|
var isReactComponent = (node) => {
|
|
4272
|
-
if (node.type ===
|
|
4729
|
+
if (node.type === import_utils68.AST_NODE_TYPES.ArrowFunctionExpression) {
|
|
4273
4730
|
const { parent } = node;
|
|
4274
|
-
if (parent?.type ===
|
|
4731
|
+
if (parent?.type === import_utils68.AST_NODE_TYPES.VariableDeclarator) {
|
|
4275
4732
|
const { id } = parent;
|
|
4276
|
-
if (id.type ===
|
|
4733
|
+
if (id.type === import_utils68.AST_NODE_TYPES.Identifier) {
|
|
4277
4734
|
return /^[A-Z]/.test(id.name);
|
|
4278
4735
|
}
|
|
4279
4736
|
}
|
|
4280
4737
|
}
|
|
4281
|
-
if (node.type ===
|
|
4738
|
+
if (node.type === import_utils68.AST_NODE_TYPES.FunctionDeclaration && node.id) {
|
|
4282
4739
|
return /^[A-Z]/.test(node.id.name);
|
|
4283
4740
|
}
|
|
4284
4741
|
return false;
|
|
4285
4742
|
};
|
|
4286
4743
|
var isCallbackFunction = (node) => {
|
|
4287
|
-
if (node.type ===
|
|
4744
|
+
if (node.type === import_utils68.AST_NODE_TYPES.FunctionDeclaration) {
|
|
4288
4745
|
return false;
|
|
4289
4746
|
}
|
|
4290
4747
|
const { parent } = node;
|
|
4291
4748
|
if (!parent) {
|
|
4292
4749
|
return false;
|
|
4293
4750
|
}
|
|
4294
|
-
if (parent.type ===
|
|
4751
|
+
if (parent.type === import_utils68.AST_NODE_TYPES.CallExpression && parent.arguments.includes(node)) {
|
|
4295
4752
|
return true;
|
|
4296
4753
|
}
|
|
4297
|
-
if (parent.type ===
|
|
4754
|
+
if (parent.type === import_utils68.AST_NODE_TYPES.Property) {
|
|
4298
4755
|
return true;
|
|
4299
4756
|
}
|
|
4300
|
-
if (parent.type ===
|
|
4757
|
+
if (parent.type === import_utils68.AST_NODE_TYPES.ArrayExpression) {
|
|
4301
4758
|
return true;
|
|
4302
4759
|
}
|
|
4303
4760
|
return false;
|
|
4304
4761
|
};
|
|
4305
4762
|
var getFunctionName = (node) => {
|
|
4306
|
-
if (node.type ===
|
|
4763
|
+
if (node.type === import_utils68.AST_NODE_TYPES.FunctionDeclaration && node.id) {
|
|
4307
4764
|
return node.id.name;
|
|
4308
4765
|
}
|
|
4309
|
-
if (node.type ===
|
|
4766
|
+
if (node.type === import_utils68.AST_NODE_TYPES.FunctionExpression && node.id) {
|
|
4310
4767
|
return node.id.name;
|
|
4311
4768
|
}
|
|
4312
|
-
if ((node.type ===
|
|
4769
|
+
if ((node.type === import_utils68.AST_NODE_TYPES.ArrowFunctionExpression || node.type === import_utils68.AST_NODE_TYPES.FunctionExpression) && node.parent?.type === import_utils68.AST_NODE_TYPES.VariableDeclarator && node.parent.id.type === import_utils68.AST_NODE_TYPES.Identifier) {
|
|
4313
4770
|
return node.parent.id.name;
|
|
4314
4771
|
}
|
|
4315
4772
|
return null;
|
|
4316
4773
|
};
|
|
4317
|
-
var requireExplicitReturnType =
|
|
4774
|
+
var requireExplicitReturnType = createRule59({
|
|
4318
4775
|
name: "require-explicit-return-type",
|
|
4319
4776
|
meta: {
|
|
4320
4777
|
type: "suggestion",
|
|
@@ -4363,8 +4820,8 @@ var requireExplicitReturnType = createRule55({
|
|
|
4363
4820
|
var require_explicit_return_type_default = requireExplicitReturnType;
|
|
4364
4821
|
|
|
4365
4822
|
// src/rules/sort-exports.ts
|
|
4366
|
-
var
|
|
4367
|
-
var
|
|
4823
|
+
var import_utils69 = require("@typescript-eslint/utils");
|
|
4824
|
+
var createRule60 = import_utils69.ESLintUtils.RuleCreator(
|
|
4368
4825
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
4369
4826
|
);
|
|
4370
4827
|
var GROUP_NAMES = ["", "external/alias re-export", "relative re-export", "local export"];
|
|
@@ -4378,7 +4835,7 @@ function getExportGroup(node) {
|
|
|
4378
4835
|
}
|
|
4379
4836
|
return 1;
|
|
4380
4837
|
}
|
|
4381
|
-
var sortExports =
|
|
4838
|
+
var sortExports = createRule60({
|
|
4382
4839
|
name: "sort-exports",
|
|
4383
4840
|
meta: {
|
|
4384
4841
|
type: "suggestion",
|
|
@@ -4418,7 +4875,7 @@ var sortExports = createRule56({
|
|
|
4418
4875
|
Program(node) {
|
|
4419
4876
|
const exportGroups = [];
|
|
4420
4877
|
node.body.forEach((statement) => {
|
|
4421
|
-
if (statement.type !==
|
|
4878
|
+
if (statement.type !== import_utils69.AST_NODE_TYPES.ExportNamedDeclaration || statement.declaration !== null) {
|
|
4422
4879
|
if (exportGroups.length > 0) {
|
|
4423
4880
|
checkOrder(exportGroups);
|
|
4424
4881
|
exportGroups.length = 0;
|
|
@@ -4437,8 +4894,8 @@ var sortExports = createRule56({
|
|
|
4437
4894
|
var sort_exports_default = sortExports;
|
|
4438
4895
|
|
|
4439
4896
|
// src/rules/sort-imports.ts
|
|
4440
|
-
var
|
|
4441
|
-
var
|
|
4897
|
+
var import_utils70 = require("@typescript-eslint/utils");
|
|
4898
|
+
var createRule61 = import_utils70.ESLintUtils.RuleCreator(
|
|
4442
4899
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
4443
4900
|
);
|
|
4444
4901
|
var NODE_BUILTINS = /* @__PURE__ */ new Set([
|
|
@@ -4505,7 +4962,7 @@ function getImportGroup(node) {
|
|
|
4505
4962
|
function isTypeOnlyImport(node) {
|
|
4506
4963
|
return node.importKind === "type" && node.specifiers.length > 0;
|
|
4507
4964
|
}
|
|
4508
|
-
var sortImports =
|
|
4965
|
+
var sortImports = createRule61({
|
|
4509
4966
|
name: "sort-imports",
|
|
4510
4967
|
meta: {
|
|
4511
4968
|
type: "suggestion",
|
|
@@ -4549,7 +5006,7 @@ var sortImports = createRule57({
|
|
|
4549
5006
|
Program(node) {
|
|
4550
5007
|
const importGroups = [];
|
|
4551
5008
|
node.body.forEach((statement) => {
|
|
4552
|
-
if (statement.type !==
|
|
5009
|
+
if (statement.type !== import_utils70.AST_NODE_TYPES.ImportDeclaration) {
|
|
4553
5010
|
if (importGroups.length > 0) {
|
|
4554
5011
|
checkOrder(importGroups);
|
|
4555
5012
|
importGroups.length = 0;
|
|
@@ -4571,13 +5028,13 @@ var sortImports = createRule57({
|
|
|
4571
5028
|
var sort_imports_default = sortImports;
|
|
4572
5029
|
|
|
4573
5030
|
// src/rules/sort-type-alphabetically.ts
|
|
4574
|
-
var
|
|
4575
|
-
var
|
|
5031
|
+
var import_utils71 = require("@typescript-eslint/utils");
|
|
5032
|
+
var createRule62 = import_utils71.ESLintUtils.RuleCreator(
|
|
4576
5033
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
4577
5034
|
);
|
|
4578
5035
|
function isAlphabeticallySortedWithinGroups(members) {
|
|
4579
5036
|
const properties = members.filter(
|
|
4580
|
-
(member) => member.type ===
|
|
5037
|
+
(member) => member.type === import_utils71.AST_NODE_TYPES.TSPropertySignature && member.key.type === import_utils71.AST_NODE_TYPES.Identifier
|
|
4581
5038
|
);
|
|
4582
5039
|
if (properties.length < 2) {
|
|
4583
5040
|
return true;
|
|
@@ -4588,7 +5045,7 @@ function isAlphabeticallySortedWithinGroups(members) {
|
|
|
4588
5045
|
const isOptionalSorted = optional.every((name, index) => index === 0 || optional[index - 1].localeCompare(name) <= 0);
|
|
4589
5046
|
return isRequiredSorted && isOptionalSorted;
|
|
4590
5047
|
}
|
|
4591
|
-
var sortTypeAlphabetically =
|
|
5048
|
+
var sortTypeAlphabetically = createRule62({
|
|
4592
5049
|
name: "sort-type-alphabetically",
|
|
4593
5050
|
meta: {
|
|
4594
5051
|
type: "suggestion",
|
|
@@ -4606,7 +5063,7 @@ var sortTypeAlphabetically = createRule58({
|
|
|
4606
5063
|
function fixMembers(fixer, members) {
|
|
4607
5064
|
const { sourceCode } = context;
|
|
4608
5065
|
const properties = members.filter(
|
|
4609
|
-
(member) => member.type ===
|
|
5066
|
+
(member) => member.type === import_utils71.AST_NODE_TYPES.TSPropertySignature && member.key.type === import_utils71.AST_NODE_TYPES.Identifier
|
|
4610
5067
|
);
|
|
4611
5068
|
const required = properties.filter((prop) => !prop.optional);
|
|
4612
5069
|
const optional = properties.filter((prop) => prop.optional);
|
|
@@ -4643,7 +5100,7 @@ var sortTypeAlphabetically = createRule58({
|
|
|
4643
5100
|
}
|
|
4644
5101
|
},
|
|
4645
5102
|
TSTypeAliasDeclaration(node) {
|
|
4646
|
-
if (node.typeAnnotation.type !==
|
|
5103
|
+
if (node.typeAnnotation.type !== import_utils71.AST_NODE_TYPES.TSTypeLiteral) {
|
|
4647
5104
|
return;
|
|
4648
5105
|
}
|
|
4649
5106
|
const { members } = node.typeAnnotation;
|
|
@@ -4663,13 +5120,13 @@ var sortTypeAlphabetically = createRule58({
|
|
|
4663
5120
|
var sort_type_alphabetically_default = sortTypeAlphabetically;
|
|
4664
5121
|
|
|
4665
5122
|
// src/rules/sort-type-required-first.ts
|
|
4666
|
-
var
|
|
4667
|
-
var
|
|
5123
|
+
var import_utils72 = require("@typescript-eslint/utils");
|
|
5124
|
+
var createRule63 = import_utils72.ESLintUtils.RuleCreator(
|
|
4668
5125
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
4669
5126
|
);
|
|
4670
5127
|
function isRequiredBeforeOptional(members) {
|
|
4671
5128
|
const properties = members.filter(
|
|
4672
|
-
(member) => member.type ===
|
|
5129
|
+
(member) => member.type === import_utils72.AST_NODE_TYPES.TSPropertySignature && member.key.type === import_utils72.AST_NODE_TYPES.Identifier
|
|
4673
5130
|
);
|
|
4674
5131
|
if (properties.length < 2) {
|
|
4675
5132
|
return true;
|
|
@@ -4680,7 +5137,7 @@ function isRequiredBeforeOptional(members) {
|
|
|
4680
5137
|
}
|
|
4681
5138
|
return properties.slice(firstOptionalIndex).every((prop) => prop.optional);
|
|
4682
5139
|
}
|
|
4683
|
-
var sortTypeRequiredFirst =
|
|
5140
|
+
var sortTypeRequiredFirst = createRule63({
|
|
4684
5141
|
name: "sort-type-required-first",
|
|
4685
5142
|
meta: {
|
|
4686
5143
|
type: "suggestion",
|
|
@@ -4698,7 +5155,7 @@ var sortTypeRequiredFirst = createRule59({
|
|
|
4698
5155
|
function fixMembers(fixer, members) {
|
|
4699
5156
|
const { sourceCode } = context;
|
|
4700
5157
|
const properties = members.filter(
|
|
4701
|
-
(member) => member.type ===
|
|
5158
|
+
(member) => member.type === import_utils72.AST_NODE_TYPES.TSPropertySignature && member.key.type === import_utils72.AST_NODE_TYPES.Identifier
|
|
4702
5159
|
);
|
|
4703
5160
|
const required = properties.filter((prop) => !prop.optional);
|
|
4704
5161
|
const optional = properties.filter((prop) => prop.optional);
|
|
@@ -4719,7 +5176,7 @@ var sortTypeRequiredFirst = createRule59({
|
|
|
4719
5176
|
}
|
|
4720
5177
|
},
|
|
4721
5178
|
TSTypeAliasDeclaration(node) {
|
|
4722
|
-
if (node.typeAnnotation.type !==
|
|
5179
|
+
if (node.typeAnnotation.type !== import_utils72.AST_NODE_TYPES.TSTypeLiteral) {
|
|
4723
5180
|
return;
|
|
4724
5181
|
}
|
|
4725
5182
|
const { members } = node.typeAnnotation;
|
|
@@ -4751,14 +5208,18 @@ var rules = {
|
|
|
4751
5208
|
"enforce-property-case": enforce_property_case_default,
|
|
4752
5209
|
"enforce-props-suffix": enforce_props_suffix_default,
|
|
4753
5210
|
"enforce-readonly-component-props": enforce_readonly_component_props_default,
|
|
5211
|
+
"enforce-render-naming": enforce_render_naming_default,
|
|
4754
5212
|
"enforce-service-naming": enforce_service_naming_default,
|
|
4755
5213
|
"enforce-sorted-destructuring": enforce_sorted_destructuring_default,
|
|
4756
5214
|
"enforce-type-declaration-order": enforce_type_declaration_order_default,
|
|
4757
5215
|
"index-export-only": index_export_only_default,
|
|
4758
5216
|
"jsx-newline-between-elements": jsx_newline_between_elements_default,
|
|
5217
|
+
"jsx-no-data-array": jsx_no_data_array_default,
|
|
5218
|
+
"jsx-no-data-object": jsx_no_data_object_default,
|
|
4759
5219
|
"jsx-no-inline-object-prop": jsx_no_inline_object_prop_default,
|
|
4760
5220
|
"jsx-no-newline-single-line-elements": jsx_no_newline_single_line_elements_default,
|
|
4761
5221
|
"jsx-no-non-component-function": jsx_no_non_component_function_default,
|
|
5222
|
+
"jsx-no-sub-interface": jsx_no_sub_interface_default,
|
|
4762
5223
|
"jsx-no-ternary-null": jsx_no_ternary_null_default,
|
|
4763
5224
|
"jsx-no-variable-in-callback": jsx_no_variable_in_callback_default,
|
|
4764
5225
|
"jsx-require-suspense": jsx_require_suspense_default,
|
|
@@ -4895,10 +5356,14 @@ var baseRecommendedRules = {
|
|
|
4895
5356
|
var jsxRules = {
|
|
4896
5357
|
"nextfriday/enforce-props-suffix": "warn",
|
|
4897
5358
|
"nextfriday/enforce-readonly-component-props": "warn",
|
|
5359
|
+
"nextfriday/enforce-render-naming": "warn",
|
|
4898
5360
|
"nextfriday/jsx-newline-between-elements": "warn",
|
|
5361
|
+
"nextfriday/jsx-no-data-array": "warn",
|
|
5362
|
+
"nextfriday/jsx-no-data-object": "warn",
|
|
4899
5363
|
"nextfriday/jsx-no-inline-object-prop": "warn",
|
|
4900
5364
|
"nextfriday/jsx-no-newline-single-line-elements": "warn",
|
|
4901
5365
|
"nextfriday/jsx-no-non-component-function": "warn",
|
|
5366
|
+
"nextfriday/jsx-no-sub-interface": "warn",
|
|
4902
5367
|
"nextfriday/jsx-no-ternary-null": "warn",
|
|
4903
5368
|
"nextfriday/jsx-no-variable-in-callback": "warn",
|
|
4904
5369
|
"nextfriday/jsx-require-suspense": "warn",
|
|
@@ -4916,10 +5381,14 @@ var jsxRules = {
|
|
|
4916
5381
|
var jsxRecommendedRules = {
|
|
4917
5382
|
"nextfriday/enforce-props-suffix": "error",
|
|
4918
5383
|
"nextfriday/enforce-readonly-component-props": "error",
|
|
5384
|
+
"nextfriday/enforce-render-naming": "error",
|
|
4919
5385
|
"nextfriday/jsx-newline-between-elements": "error",
|
|
5386
|
+
"nextfriday/jsx-no-data-array": "error",
|
|
5387
|
+
"nextfriday/jsx-no-data-object": "error",
|
|
4920
5388
|
"nextfriday/jsx-no-inline-object-prop": "error",
|
|
4921
5389
|
"nextfriday/jsx-no-newline-single-line-elements": "error",
|
|
4922
5390
|
"nextfriday/jsx-no-non-component-function": "error",
|
|
5391
|
+
"nextfriday/jsx-no-sub-interface": "error",
|
|
4923
5392
|
"nextfriday/jsx-no-ternary-null": "error",
|
|
4924
5393
|
"nextfriday/jsx-no-variable-in-callback": "error",
|
|
4925
5394
|
"nextfriday/jsx-require-suspense": "error",
|