eslint-plugin-nextfriday 4.0.0 → 4.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +22 -0
- package/README.md +17 -15
- package/docs/rules/ENFORCE_RENDER_NAMING.md +96 -0
- package/docs/rules/JSX_NO_DATA_ARRAY.md +63 -0
- package/docs/rules/JSX_NO_DATA_OBJECT.md +71 -0
- package/docs/rules/JSX_NO_SUB_INTERFACE.md +86 -0
- package/docs/rules/NO_GHOST_WRAPPER.md +75 -0
- package/docs/rules/NO_REDUNDANT_FRAGMENT.md +56 -0
- package/lib/index.cjs +1037 -442
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +252 -0
- package/lib/index.d.ts +252 -0
- package/lib/index.js +1037 -442
- package/lib/index.js.map +1 -1
- package/package.json +1 -1
package/lib/index.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) {
|
|
@@ -2109,12 +2566,58 @@ var noEnvFallback = createRule27({
|
|
|
2109
2566
|
});
|
|
2110
2567
|
var no_env_fallback_default = noEnvFallback;
|
|
2111
2568
|
|
|
2569
|
+
// src/rules/no-ghost-wrapper.ts
|
|
2570
|
+
var import_utils40 = require("@typescript-eslint/utils");
|
|
2571
|
+
var createRule32 = import_utils40.ESLintUtils.RuleCreator(
|
|
2572
|
+
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2573
|
+
);
|
|
2574
|
+
var GHOST_TAGS = /* @__PURE__ */ new Set(["div", "span"]);
|
|
2575
|
+
function isKeyAttribute(attribute) {
|
|
2576
|
+
return attribute.type === import_utils40.AST_NODE_TYPES.JSXAttribute && attribute.name.type === import_utils40.AST_NODE_TYPES.JSXIdentifier && attribute.name.name === "key";
|
|
2577
|
+
}
|
|
2578
|
+
var noGhostWrapper = createRule32({
|
|
2579
|
+
name: "no-ghost-wrapper",
|
|
2580
|
+
meta: {
|
|
2581
|
+
type: "problem",
|
|
2582
|
+
docs: {
|
|
2583
|
+
description: "Disallow bare <div> and <span> elements that have no meaningful attributes (Divitis / ghost wrappers)"
|
|
2584
|
+
},
|
|
2585
|
+
schema: [],
|
|
2586
|
+
messages: {
|
|
2587
|
+
noGhostWrapper: "Ghost <{{ tag }}> has no meaningful attributes. Use a Fragment (<>...</>), a semantic element (section, article, header, etc.), or add a meaningful attribute (className, role, data-*, ref, etc.). Note: 'key' alone does not count as meaningful."
|
|
2588
|
+
}
|
|
2589
|
+
},
|
|
2590
|
+
defaultOptions: [],
|
|
2591
|
+
create(context) {
|
|
2592
|
+
return {
|
|
2593
|
+
JSXOpeningElement(node) {
|
|
2594
|
+
if (node.name.type !== import_utils40.AST_NODE_TYPES.JSXIdentifier) {
|
|
2595
|
+
return;
|
|
2596
|
+
}
|
|
2597
|
+
const tagName = node.name.name;
|
|
2598
|
+
if (!GHOST_TAGS.has(tagName)) {
|
|
2599
|
+
return;
|
|
2600
|
+
}
|
|
2601
|
+
const meaningfulAttributes = node.attributes.filter((attribute) => !isKeyAttribute(attribute));
|
|
2602
|
+
if (meaningfulAttributes.length === 0) {
|
|
2603
|
+
context.report({
|
|
2604
|
+
node,
|
|
2605
|
+
messageId: "noGhostWrapper",
|
|
2606
|
+
data: { tag: tagName }
|
|
2607
|
+
});
|
|
2608
|
+
}
|
|
2609
|
+
}
|
|
2610
|
+
};
|
|
2611
|
+
}
|
|
2612
|
+
});
|
|
2613
|
+
var no_ghost_wrapper_default = noGhostWrapper;
|
|
2614
|
+
|
|
2112
2615
|
// src/rules/no-inline-default-export.ts
|
|
2113
|
-
var
|
|
2114
|
-
var
|
|
2616
|
+
var import_utils41 = require("@typescript-eslint/utils");
|
|
2617
|
+
var createRule33 = import_utils41.ESLintUtils.RuleCreator(
|
|
2115
2618
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2116
2619
|
);
|
|
2117
|
-
var noInlineDefaultExport =
|
|
2620
|
+
var noInlineDefaultExport = createRule33({
|
|
2118
2621
|
name: "no-inline-default-export",
|
|
2119
2622
|
meta: {
|
|
2120
2623
|
type: "suggestion",
|
|
@@ -2133,7 +2636,7 @@ var noInlineDefaultExport = createRule28({
|
|
|
2133
2636
|
return {
|
|
2134
2637
|
ExportDefaultDeclaration(node) {
|
|
2135
2638
|
const { declaration } = node;
|
|
2136
|
-
if (declaration.type ===
|
|
2639
|
+
if (declaration.type === import_utils41.AST_NODE_TYPES.FunctionDeclaration) {
|
|
2137
2640
|
if (declaration.id) {
|
|
2138
2641
|
context.report({
|
|
2139
2642
|
node,
|
|
@@ -2148,7 +2651,7 @@ var noInlineDefaultExport = createRule28({
|
|
|
2148
2651
|
});
|
|
2149
2652
|
}
|
|
2150
2653
|
}
|
|
2151
|
-
if (declaration.type ===
|
|
2654
|
+
if (declaration.type === import_utils41.AST_NODE_TYPES.ClassDeclaration) {
|
|
2152
2655
|
if (declaration.id) {
|
|
2153
2656
|
context.report({
|
|
2154
2657
|
node,
|
|
@@ -2163,7 +2666,7 @@ var noInlineDefaultExport = createRule28({
|
|
|
2163
2666
|
});
|
|
2164
2667
|
}
|
|
2165
2668
|
}
|
|
2166
|
-
if (declaration.type ===
|
|
2669
|
+
if (declaration.type === import_utils41.AST_NODE_TYPES.ArrowFunctionExpression || declaration.type === import_utils41.AST_NODE_TYPES.FunctionExpression) {
|
|
2167
2670
|
context.report({
|
|
2168
2671
|
node,
|
|
2169
2672
|
messageId: "noAnonymousDefaultExport",
|
|
@@ -2176,14 +2679,14 @@ var noInlineDefaultExport = createRule28({
|
|
|
2176
2679
|
if (!declaration) {
|
|
2177
2680
|
return;
|
|
2178
2681
|
}
|
|
2179
|
-
if (declaration.type ===
|
|
2682
|
+
if (declaration.type === import_utils41.AST_NODE_TYPES.FunctionDeclaration && declaration.id) {
|
|
2180
2683
|
context.report({
|
|
2181
2684
|
node,
|
|
2182
2685
|
messageId: "noInlineNamedExport",
|
|
2183
2686
|
data: { type: "function", name: declaration.id.name }
|
|
2184
2687
|
});
|
|
2185
2688
|
}
|
|
2186
|
-
if (declaration.type ===
|
|
2689
|
+
if (declaration.type === import_utils41.AST_NODE_TYPES.ClassDeclaration && declaration.id) {
|
|
2187
2690
|
context.report({
|
|
2188
2691
|
node,
|
|
2189
2692
|
messageId: "noInlineNamedExport",
|
|
@@ -2197,27 +2700,27 @@ var noInlineDefaultExport = createRule28({
|
|
|
2197
2700
|
var no_inline_default_export_default = noInlineDefaultExport;
|
|
2198
2701
|
|
|
2199
2702
|
// src/rules/no-inline-nested-object.ts
|
|
2200
|
-
var
|
|
2201
|
-
var
|
|
2703
|
+
var import_utils42 = require("@typescript-eslint/utils");
|
|
2704
|
+
var createRule34 = import_utils42.ESLintUtils.RuleCreator(
|
|
2202
2705
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2203
2706
|
);
|
|
2204
2707
|
function isObjectOrArray(node) {
|
|
2205
|
-
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;
|
|
2206
2709
|
}
|
|
2207
2710
|
function getInnerExpression(node) {
|
|
2208
|
-
if (node.type ===
|
|
2711
|
+
if (node.type === import_utils42.AST_NODE_TYPES.TSAsExpression) {
|
|
2209
2712
|
return getInnerExpression(node.expression);
|
|
2210
2713
|
}
|
|
2211
2714
|
return node;
|
|
2212
2715
|
}
|
|
2213
2716
|
function isNestedStructure(node) {
|
|
2214
2717
|
const inner = getInnerExpression(node);
|
|
2215
|
-
return inner.type ===
|
|
2718
|
+
return inner.type === import_utils42.AST_NODE_TYPES.ObjectExpression || inner.type === import_utils42.AST_NODE_TYPES.ArrayExpression;
|
|
2216
2719
|
}
|
|
2217
2720
|
function containsNestedStructure(node) {
|
|
2218
|
-
if (node.type ===
|
|
2721
|
+
if (node.type === import_utils42.AST_NODE_TYPES.ObjectExpression) {
|
|
2219
2722
|
return node.properties.some((prop) => {
|
|
2220
|
-
if (prop.type !==
|
|
2723
|
+
if (prop.type !== import_utils42.AST_NODE_TYPES.Property) return false;
|
|
2221
2724
|
return isNestedStructure(prop.value);
|
|
2222
2725
|
});
|
|
2223
2726
|
}
|
|
@@ -2226,7 +2729,7 @@ function containsNestedStructure(node) {
|
|
|
2226
2729
|
return isNestedStructure(el);
|
|
2227
2730
|
});
|
|
2228
2731
|
}
|
|
2229
|
-
var noInlineNestedObject =
|
|
2732
|
+
var noInlineNestedObject = createRule34({
|
|
2230
2733
|
name: "no-inline-nested-object",
|
|
2231
2734
|
meta: {
|
|
2232
2735
|
type: "layout",
|
|
@@ -2248,7 +2751,7 @@ var noInlineNestedObject = createRule29({
|
|
|
2248
2751
|
return;
|
|
2249
2752
|
}
|
|
2250
2753
|
const valueNode = getInnerExpression(node.value);
|
|
2251
|
-
if (valueNode.type !==
|
|
2754
|
+
if (valueNode.type !== import_utils42.AST_NODE_TYPES.ObjectExpression && valueNode.type !== import_utils42.AST_NODE_TYPES.ArrayExpression) {
|
|
2252
2755
|
return;
|
|
2253
2756
|
}
|
|
2254
2757
|
if (!valueNode.loc) {
|
|
@@ -2261,7 +2764,7 @@ var noInlineNestedObject = createRule29({
|
|
|
2261
2764
|
if (!containsNestedStructure(valueNode)) {
|
|
2262
2765
|
return;
|
|
2263
2766
|
}
|
|
2264
|
-
const elements = valueNode.type ===
|
|
2767
|
+
const elements = valueNode.type === import_utils42.AST_NODE_TYPES.ObjectExpression ? valueNode.properties : valueNode.elements;
|
|
2265
2768
|
context.report({
|
|
2266
2769
|
node: valueNode,
|
|
2267
2770
|
messageId: "requireMultiline",
|
|
@@ -2274,7 +2777,7 @@ var noInlineNestedObject = createRule29({
|
|
|
2274
2777
|
const indent = " ".repeat(node.loc?.start.column ?? 0);
|
|
2275
2778
|
const innerIndent = `${indent} `;
|
|
2276
2779
|
const elementTexts = elements.filter((el) => el !== null).map((el) => sourceCode.getText(el));
|
|
2277
|
-
const isObject = valueNode.type ===
|
|
2780
|
+
const isObject = valueNode.type === import_utils42.AST_NODE_TYPES.ObjectExpression;
|
|
2278
2781
|
const openChar = isObject ? "{" : "[";
|
|
2279
2782
|
const closeChar = isObject ? "}" : "]";
|
|
2280
2783
|
const formattedElements = elementTexts.map((text) => `${innerIndent}${text},`).join("\n");
|
|
@@ -2291,20 +2794,20 @@ ${indent}${closeChar}`;
|
|
|
2291
2794
|
var no_inline_nested_object_default = noInlineNestedObject;
|
|
2292
2795
|
|
|
2293
2796
|
// src/rules/no-inline-return-properties.ts
|
|
2294
|
-
var
|
|
2295
|
-
var
|
|
2797
|
+
var import_utils43 = require("@typescript-eslint/utils");
|
|
2798
|
+
var createRule35 = import_utils43.ESLintUtils.RuleCreator(
|
|
2296
2799
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2297
2800
|
);
|
|
2298
2801
|
var isShorthandProperty = (property) => {
|
|
2299
|
-
if (property.type ===
|
|
2802
|
+
if (property.type === import_utils43.AST_NODE_TYPES.SpreadElement) {
|
|
2300
2803
|
return true;
|
|
2301
2804
|
}
|
|
2302
|
-
if (property.type !==
|
|
2805
|
+
if (property.type !== import_utils43.AST_NODE_TYPES.Property) {
|
|
2303
2806
|
return false;
|
|
2304
2807
|
}
|
|
2305
2808
|
return property.shorthand;
|
|
2306
2809
|
};
|
|
2307
|
-
var noInlineReturnProperties =
|
|
2810
|
+
var noInlineReturnProperties = createRule35({
|
|
2308
2811
|
name: "no-inline-return-properties",
|
|
2309
2812
|
meta: {
|
|
2310
2813
|
type: "suggestion",
|
|
@@ -2320,20 +2823,20 @@ var noInlineReturnProperties = createRule30({
|
|
|
2320
2823
|
create(context) {
|
|
2321
2824
|
return {
|
|
2322
2825
|
ReturnStatement(node) {
|
|
2323
|
-
if (!node.argument || node.argument.type !==
|
|
2826
|
+
if (!node.argument || node.argument.type !== import_utils43.AST_NODE_TYPES.ObjectExpression) {
|
|
2324
2827
|
return;
|
|
2325
2828
|
}
|
|
2326
2829
|
node.argument.properties.forEach((property) => {
|
|
2327
2830
|
if (isShorthandProperty(property)) {
|
|
2328
2831
|
return;
|
|
2329
2832
|
}
|
|
2330
|
-
if (property.type !==
|
|
2833
|
+
if (property.type !== import_utils43.AST_NODE_TYPES.Property) {
|
|
2331
2834
|
return;
|
|
2332
2835
|
}
|
|
2333
2836
|
let keyName = null;
|
|
2334
|
-
if (property.key.type ===
|
|
2837
|
+
if (property.key.type === import_utils43.AST_NODE_TYPES.Identifier) {
|
|
2335
2838
|
keyName = property.key.name;
|
|
2336
|
-
} else if (property.key.type ===
|
|
2839
|
+
} else if (property.key.type === import_utils43.AST_NODE_TYPES.Literal) {
|
|
2337
2840
|
keyName = String(property.key.value);
|
|
2338
2841
|
}
|
|
2339
2842
|
context.report({
|
|
@@ -2349,12 +2852,12 @@ var noInlineReturnProperties = createRule30({
|
|
|
2349
2852
|
var no_inline_return_properties_default = noInlineReturnProperties;
|
|
2350
2853
|
|
|
2351
2854
|
// src/rules/no-inline-type-import.ts
|
|
2352
|
-
var
|
|
2353
|
-
var
|
|
2855
|
+
var import_utils44 = require("@typescript-eslint/utils");
|
|
2856
|
+
var createRule36 = import_utils44.ESLintUtils.RuleCreator(
|
|
2354
2857
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2355
2858
|
);
|
|
2356
|
-
var isInlineTypeSpecifier = (specifier) => specifier.type ===
|
|
2357
|
-
var noInlineTypeImport =
|
|
2859
|
+
var isInlineTypeSpecifier = (specifier) => specifier.type === import_utils44.AST_NODE_TYPES.ImportSpecifier && specifier.importKind === "type";
|
|
2860
|
+
var noInlineTypeImport = createRule36({
|
|
2358
2861
|
name: "no-inline-type-import",
|
|
2359
2862
|
meta: {
|
|
2360
2863
|
type: "suggestion",
|
|
@@ -2391,7 +2894,7 @@ var noInlineTypeImport = createRule31({
|
|
|
2391
2894
|
);
|
|
2392
2895
|
const typeImport = `import type { ${typeSpecifierTexts.join(", ")} } from ${sourceText};`;
|
|
2393
2896
|
const valueSpecifiers = node.specifiers.filter(
|
|
2394
|
-
(specifier) => !(specifier.type ===
|
|
2897
|
+
(specifier) => !(specifier.type === import_utils44.AST_NODE_TYPES.ImportSpecifier && specifier.importKind === "type")
|
|
2395
2898
|
);
|
|
2396
2899
|
if (valueSpecifiers.length === 0) {
|
|
2397
2900
|
return fixer.replaceText(node, typeImport);
|
|
@@ -2399,11 +2902,11 @@ var noInlineTypeImport = createRule31({
|
|
|
2399
2902
|
const parts = [];
|
|
2400
2903
|
const namedValueSpecifiers = [];
|
|
2401
2904
|
for (const specifier of valueSpecifiers) {
|
|
2402
|
-
if (specifier.type ===
|
|
2905
|
+
if (specifier.type === import_utils44.AST_NODE_TYPES.ImportDefaultSpecifier) {
|
|
2403
2906
|
parts.push(specifier.local.name);
|
|
2404
|
-
} else if (specifier.type ===
|
|
2907
|
+
} else if (specifier.type === import_utils44.AST_NODE_TYPES.ImportNamespaceSpecifier) {
|
|
2405
2908
|
parts.push(`* as ${specifier.local.name}`);
|
|
2406
|
-
} else if (specifier.type ===
|
|
2909
|
+
} else if (specifier.type === import_utils44.AST_NODE_TYPES.ImportSpecifier) {
|
|
2407
2910
|
namedValueSpecifiers.push(specifier);
|
|
2408
2911
|
}
|
|
2409
2912
|
}
|
|
@@ -2423,8 +2926,8 @@ ${typeImport}`);
|
|
|
2423
2926
|
var no_inline_type_import_default = noInlineTypeImport;
|
|
2424
2927
|
|
|
2425
2928
|
// src/rules/no-lazy-identifiers.ts
|
|
2426
|
-
var
|
|
2427
|
-
var
|
|
2929
|
+
var import_utils45 = require("@typescript-eslint/utils");
|
|
2930
|
+
var createRule37 = import_utils45.ESLintUtils.RuleCreator(
|
|
2428
2931
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2429
2932
|
);
|
|
2430
2933
|
var KEYBOARD_ROWS = ["qwertyuiop", "asdfghjkl", "zxcvbnm", "1234567890"];
|
|
@@ -2465,7 +2968,7 @@ var isLazyIdentifier = (name) => {
|
|
|
2465
2968
|
}
|
|
2466
2969
|
return false;
|
|
2467
2970
|
};
|
|
2468
|
-
var noLazyIdentifiers =
|
|
2971
|
+
var noLazyIdentifiers = createRule37({
|
|
2469
2972
|
name: "no-lazy-identifiers",
|
|
2470
2973
|
meta: {
|
|
2471
2974
|
type: "problem",
|
|
@@ -2491,27 +2994,27 @@ var noLazyIdentifiers = createRule32({
|
|
|
2491
2994
|
});
|
|
2492
2995
|
};
|
|
2493
2996
|
const checkPattern = (pattern) => {
|
|
2494
|
-
if (pattern.type ===
|
|
2997
|
+
if (pattern.type === import_utils45.AST_NODE_TYPES.Identifier) {
|
|
2495
2998
|
checkIdentifier(pattern);
|
|
2496
|
-
} else if (pattern.type ===
|
|
2999
|
+
} else if (pattern.type === import_utils45.AST_NODE_TYPES.ObjectPattern) {
|
|
2497
3000
|
pattern.properties.forEach((prop) => {
|
|
2498
|
-
if (prop.type ===
|
|
3001
|
+
if (prop.type === import_utils45.AST_NODE_TYPES.Property && prop.value.type === import_utils45.AST_NODE_TYPES.Identifier) {
|
|
2499
3002
|
checkIdentifier(prop.value);
|
|
2500
|
-
} else if (prop.type ===
|
|
3003
|
+
} else if (prop.type === import_utils45.AST_NODE_TYPES.RestElement && prop.argument.type === import_utils45.AST_NODE_TYPES.Identifier) {
|
|
2501
3004
|
checkIdentifier(prop.argument);
|
|
2502
3005
|
}
|
|
2503
3006
|
});
|
|
2504
|
-
} else if (pattern.type ===
|
|
3007
|
+
} else if (pattern.type === import_utils45.AST_NODE_TYPES.ArrayPattern) {
|
|
2505
3008
|
pattern.elements.forEach((element) => {
|
|
2506
|
-
if (element?.type ===
|
|
3009
|
+
if (element?.type === import_utils45.AST_NODE_TYPES.Identifier) {
|
|
2507
3010
|
checkIdentifier(element);
|
|
2508
|
-
} else if (element?.type ===
|
|
3011
|
+
} else if (element?.type === import_utils45.AST_NODE_TYPES.RestElement && element.argument.type === import_utils45.AST_NODE_TYPES.Identifier) {
|
|
2509
3012
|
checkIdentifier(element.argument);
|
|
2510
3013
|
}
|
|
2511
3014
|
});
|
|
2512
|
-
} else if (pattern.type ===
|
|
3015
|
+
} else if (pattern.type === import_utils45.AST_NODE_TYPES.AssignmentPattern && pattern.left.type === import_utils45.AST_NODE_TYPES.Identifier) {
|
|
2513
3016
|
checkIdentifier(pattern.left);
|
|
2514
|
-
} else if (pattern.type ===
|
|
3017
|
+
} else if (pattern.type === import_utils45.AST_NODE_TYPES.RestElement && pattern.argument.type === import_utils45.AST_NODE_TYPES.Identifier) {
|
|
2515
3018
|
checkIdentifier(pattern.argument);
|
|
2516
3019
|
}
|
|
2517
3020
|
};
|
|
@@ -2556,11 +3059,11 @@ var noLazyIdentifiers = createRule32({
|
|
|
2556
3059
|
var no_lazy_identifiers_default = noLazyIdentifiers;
|
|
2557
3060
|
|
|
2558
3061
|
// src/rules/no-logic-in-params.ts
|
|
2559
|
-
var
|
|
2560
|
-
var
|
|
3062
|
+
var import_utils46 = require("@typescript-eslint/utils");
|
|
3063
|
+
var createRule38 = import_utils46.ESLintUtils.RuleCreator(
|
|
2561
3064
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2562
3065
|
);
|
|
2563
|
-
var noLogicInParams =
|
|
3066
|
+
var noLogicInParams = createRule38({
|
|
2564
3067
|
name: "no-logic-in-params",
|
|
2565
3068
|
meta: {
|
|
2566
3069
|
type: "suggestion",
|
|
@@ -2575,20 +3078,20 @@ var noLogicInParams = createRule33({
|
|
|
2575
3078
|
defaultOptions: [],
|
|
2576
3079
|
create(context) {
|
|
2577
3080
|
const isComplexExpression = (node) => {
|
|
2578
|
-
if (node.type ===
|
|
3081
|
+
if (node.type === import_utils46.AST_NODE_TYPES.SpreadElement) {
|
|
2579
3082
|
return false;
|
|
2580
3083
|
}
|
|
2581
|
-
if (node.type ===
|
|
3084
|
+
if (node.type === import_utils46.AST_NODE_TYPES.ConditionalExpression) {
|
|
2582
3085
|
return true;
|
|
2583
3086
|
}
|
|
2584
|
-
if (node.type ===
|
|
3087
|
+
if (node.type === import_utils46.AST_NODE_TYPES.LogicalExpression) {
|
|
2585
3088
|
return true;
|
|
2586
3089
|
}
|
|
2587
|
-
if (node.type ===
|
|
3090
|
+
if (node.type === import_utils46.AST_NODE_TYPES.BinaryExpression) {
|
|
2588
3091
|
const logicalOperators = ["==", "===", "!=", "!==", "<", ">", "<=", ">=", "in", "instanceof"];
|
|
2589
3092
|
return logicalOperators.includes(node.operator);
|
|
2590
3093
|
}
|
|
2591
|
-
if (node.type ===
|
|
3094
|
+
if (node.type === import_utils46.AST_NODE_TYPES.UnaryExpression) {
|
|
2592
3095
|
return node.operator === "!";
|
|
2593
3096
|
}
|
|
2594
3097
|
return false;
|
|
@@ -2601,7 +3104,7 @@ var noLogicInParams = createRule33({
|
|
|
2601
3104
|
messageId: "noLogicInParams"
|
|
2602
3105
|
});
|
|
2603
3106
|
}
|
|
2604
|
-
if (arg.type ===
|
|
3107
|
+
if (arg.type === import_utils46.AST_NODE_TYPES.ArrayExpression) {
|
|
2605
3108
|
arg.elements.forEach((element) => {
|
|
2606
3109
|
if (element && isComplexExpression(element)) {
|
|
2607
3110
|
context.report({
|
|
@@ -2626,46 +3129,46 @@ var noLogicInParams = createRule33({
|
|
|
2626
3129
|
var no_logic_in_params_default = noLogicInParams;
|
|
2627
3130
|
|
|
2628
3131
|
// src/rules/no-misleading-constant-case.ts
|
|
2629
|
-
var
|
|
2630
|
-
var
|
|
3132
|
+
var import_utils47 = require("@typescript-eslint/utils");
|
|
3133
|
+
var createRule39 = import_utils47.ESLintUtils.RuleCreator(
|
|
2631
3134
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2632
3135
|
);
|
|
2633
3136
|
var SCREAMING_SNAKE_CASE_REGEX3 = /^[A-Z][A-Z0-9]*(?:_[A-Z0-9]+)*$/;
|
|
2634
|
-
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";
|
|
2635
3138
|
var isStaticValue2 = (init) => {
|
|
2636
3139
|
if (isAsConstAssertion(init)) {
|
|
2637
3140
|
return true;
|
|
2638
3141
|
}
|
|
2639
|
-
if (init.type ===
|
|
3142
|
+
if (init.type === import_utils47.AST_NODE_TYPES.Literal) {
|
|
2640
3143
|
return true;
|
|
2641
3144
|
}
|
|
2642
|
-
if (init.type ===
|
|
3145
|
+
if (init.type === import_utils47.AST_NODE_TYPES.UnaryExpression && init.argument.type === import_utils47.AST_NODE_TYPES.Literal) {
|
|
2643
3146
|
return true;
|
|
2644
3147
|
}
|
|
2645
|
-
if (init.type ===
|
|
3148
|
+
if (init.type === import_utils47.AST_NODE_TYPES.TemplateLiteral && init.expressions.length === 0) {
|
|
2646
3149
|
return true;
|
|
2647
3150
|
}
|
|
2648
|
-
if (init.type ===
|
|
2649
|
-
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));
|
|
2650
3153
|
}
|
|
2651
|
-
if (init.type ===
|
|
3154
|
+
if (init.type === import_utils47.AST_NODE_TYPES.ObjectExpression) {
|
|
2652
3155
|
return init.properties.every(
|
|
2653
|
-
(prop) => prop.type ===
|
|
3156
|
+
(prop) => prop.type === import_utils47.AST_NODE_TYPES.Property && isStaticValue2(prop.value)
|
|
2654
3157
|
);
|
|
2655
3158
|
}
|
|
2656
3159
|
return false;
|
|
2657
3160
|
};
|
|
2658
3161
|
var isGlobalScope3 = (node) => {
|
|
2659
3162
|
const { parent } = node;
|
|
2660
|
-
if (parent.type ===
|
|
3163
|
+
if (parent.type === import_utils47.AST_NODE_TYPES.Program) {
|
|
2661
3164
|
return true;
|
|
2662
3165
|
}
|
|
2663
|
-
if (parent.type ===
|
|
3166
|
+
if (parent.type === import_utils47.AST_NODE_TYPES.ExportNamedDeclaration && parent.parent?.type === import_utils47.AST_NODE_TYPES.Program) {
|
|
2664
3167
|
return true;
|
|
2665
3168
|
}
|
|
2666
3169
|
return false;
|
|
2667
3170
|
};
|
|
2668
|
-
var noMisleadingConstantCase =
|
|
3171
|
+
var noMisleadingConstantCase = createRule39({
|
|
2669
3172
|
name: "no-misleading-constant-case",
|
|
2670
3173
|
meta: {
|
|
2671
3174
|
type: "suggestion",
|
|
@@ -2684,7 +3187,7 @@ var noMisleadingConstantCase = createRule34({
|
|
|
2684
3187
|
return {
|
|
2685
3188
|
VariableDeclaration(node) {
|
|
2686
3189
|
node.declarations.forEach((declarator) => {
|
|
2687
|
-
if (declarator.id.type !==
|
|
3190
|
+
if (declarator.id.type !== import_utils47.AST_NODE_TYPES.Identifier) {
|
|
2688
3191
|
return;
|
|
2689
3192
|
}
|
|
2690
3193
|
const { name } = declarator.id;
|
|
@@ -2725,11 +3228,11 @@ var noMisleadingConstantCase = createRule34({
|
|
|
2725
3228
|
var no_misleading_constant_case_default = noMisleadingConstantCase;
|
|
2726
3229
|
|
|
2727
3230
|
// src/rules/no-nested-interface-declaration.ts
|
|
2728
|
-
var
|
|
2729
|
-
var
|
|
3231
|
+
var import_utils48 = require("@typescript-eslint/utils");
|
|
3232
|
+
var createRule40 = import_utils48.ESLintUtils.RuleCreator(
|
|
2730
3233
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2731
3234
|
);
|
|
2732
|
-
var noNestedInterfaceDeclaration =
|
|
3235
|
+
var noNestedInterfaceDeclaration = createRule40({
|
|
2733
3236
|
name: "no-nested-interface-declaration",
|
|
2734
3237
|
meta: {
|
|
2735
3238
|
type: "suggestion",
|
|
@@ -2750,15 +3253,15 @@ var noNestedInterfaceDeclaration = createRule35({
|
|
|
2750
3253
|
return;
|
|
2751
3254
|
}
|
|
2752
3255
|
const { typeAnnotation } = node.typeAnnotation;
|
|
2753
|
-
if (typeAnnotation.type ===
|
|
3256
|
+
if (typeAnnotation.type === import_utils48.AST_NODE_TYPES.TSTypeLiteral) {
|
|
2754
3257
|
context.report({
|
|
2755
3258
|
node: typeAnnotation,
|
|
2756
3259
|
messageId: "noNestedInterface"
|
|
2757
3260
|
});
|
|
2758
3261
|
return;
|
|
2759
3262
|
}
|
|
2760
|
-
if (typeAnnotation.type ===
|
|
2761
|
-
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) {
|
|
2762
3265
|
context.report({
|
|
2763
3266
|
node: typeAnnotation.elementType,
|
|
2764
3267
|
messageId: "noNestedInterface"
|
|
@@ -2766,9 +3269,9 @@ var noNestedInterfaceDeclaration = createRule35({
|
|
|
2766
3269
|
}
|
|
2767
3270
|
return;
|
|
2768
3271
|
}
|
|
2769
|
-
if (typeAnnotation.type ===
|
|
3272
|
+
if (typeAnnotation.type === import_utils48.AST_NODE_TYPES.TSTypeReference && typeAnnotation.typeArguments) {
|
|
2770
3273
|
typeAnnotation.typeArguments.params.forEach((param) => {
|
|
2771
|
-
if (param.type ===
|
|
3274
|
+
if (param.type === import_utils48.AST_NODE_TYPES.TSTypeLiteral) {
|
|
2772
3275
|
context.report({
|
|
2773
3276
|
node: param,
|
|
2774
3277
|
messageId: "noNestedInterface"
|
|
@@ -2783,11 +3286,11 @@ var noNestedInterfaceDeclaration = createRule35({
|
|
|
2783
3286
|
var no_nested_interface_declaration_default = noNestedInterfaceDeclaration;
|
|
2784
3287
|
|
|
2785
3288
|
// src/rules/no-nested-ternary.ts
|
|
2786
|
-
var
|
|
2787
|
-
var
|
|
3289
|
+
var import_utils49 = require("@typescript-eslint/utils");
|
|
3290
|
+
var createRule41 = import_utils49.ESLintUtils.RuleCreator(
|
|
2788
3291
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2789
3292
|
);
|
|
2790
|
-
var noNestedTernary =
|
|
3293
|
+
var noNestedTernary = createRule41({
|
|
2791
3294
|
name: "no-nested-ternary",
|
|
2792
3295
|
meta: {
|
|
2793
3296
|
type: "suggestion",
|
|
@@ -2804,13 +3307,13 @@ var noNestedTernary = createRule36({
|
|
|
2804
3307
|
return {
|
|
2805
3308
|
ConditionalExpression(node) {
|
|
2806
3309
|
const { consequent, alternate } = node;
|
|
2807
|
-
if (consequent.type ===
|
|
3310
|
+
if (consequent.type === import_utils49.AST_NODE_TYPES.ConditionalExpression) {
|
|
2808
3311
|
context.report({
|
|
2809
3312
|
node: consequent,
|
|
2810
3313
|
messageId: "noNestedTernary"
|
|
2811
3314
|
});
|
|
2812
3315
|
}
|
|
2813
|
-
if (alternate.type ===
|
|
3316
|
+
if (alternate.type === import_utils49.AST_NODE_TYPES.ConditionalExpression) {
|
|
2814
3317
|
context.report({
|
|
2815
3318
|
node: alternate,
|
|
2816
3319
|
messageId: "noNestedTernary"
|
|
@@ -2822,12 +3325,86 @@ var noNestedTernary = createRule36({
|
|
|
2822
3325
|
});
|
|
2823
3326
|
var no_nested_ternary_default = noNestedTernary;
|
|
2824
3327
|
|
|
3328
|
+
// src/rules/no-redundant-fragment.ts
|
|
3329
|
+
var import_utils50 = require("@typescript-eslint/utils");
|
|
3330
|
+
var createRule42 = import_utils50.ESLintUtils.RuleCreator(
|
|
3331
|
+
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3332
|
+
);
|
|
3333
|
+
function isFragmentName(name) {
|
|
3334
|
+
if (name.type === import_utils50.AST_NODE_TYPES.JSXIdentifier && name.name === "Fragment") {
|
|
3335
|
+
return true;
|
|
3336
|
+
}
|
|
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") {
|
|
3338
|
+
return true;
|
|
3339
|
+
}
|
|
3340
|
+
return false;
|
|
3341
|
+
}
|
|
3342
|
+
function hasKeyAttribute(attributes) {
|
|
3343
|
+
return attributes.some(
|
|
3344
|
+
(attribute) => attribute.type === import_utils50.AST_NODE_TYPES.JSXAttribute && attribute.name.type === import_utils50.AST_NODE_TYPES.JSXIdentifier && attribute.name.name === "key"
|
|
3345
|
+
);
|
|
3346
|
+
}
|
|
3347
|
+
function countMeaningfulChildren(children) {
|
|
3348
|
+
return children.filter((child) => {
|
|
3349
|
+
if (child.type === import_utils50.AST_NODE_TYPES.JSXText) {
|
|
3350
|
+
return child.value.trim() !== "";
|
|
3351
|
+
}
|
|
3352
|
+
return true;
|
|
3353
|
+
}).length;
|
|
3354
|
+
}
|
|
3355
|
+
var noRedundantFragment = createRule42({
|
|
3356
|
+
name: "no-redundant-fragment",
|
|
3357
|
+
meta: {
|
|
3358
|
+
type: "problem",
|
|
3359
|
+
docs: {
|
|
3360
|
+
description: "Disallow Fragments that wrap zero or one child (unless a key prop is needed)"
|
|
3361
|
+
},
|
|
3362
|
+
schema: [],
|
|
3363
|
+
messages: {
|
|
3364
|
+
redundantFragment: "Fragment is redundant when wrapping {{ count }} child. Remove the Fragment or replace it with the child directly."
|
|
3365
|
+
}
|
|
3366
|
+
},
|
|
3367
|
+
defaultOptions: [],
|
|
3368
|
+
create(context) {
|
|
3369
|
+
return {
|
|
3370
|
+
JSXFragment(node) {
|
|
3371
|
+
const count = countMeaningfulChildren(node.children);
|
|
3372
|
+
if (count <= 1) {
|
|
3373
|
+
context.report({
|
|
3374
|
+
node,
|
|
3375
|
+
messageId: "redundantFragment",
|
|
3376
|
+
data: { count: String(count) }
|
|
3377
|
+
});
|
|
3378
|
+
}
|
|
3379
|
+
},
|
|
3380
|
+
JSXElement(node) {
|
|
3381
|
+
const opening = node.openingElement;
|
|
3382
|
+
if (!isFragmentName(opening.name)) {
|
|
3383
|
+
return;
|
|
3384
|
+
}
|
|
3385
|
+
if (hasKeyAttribute(opening.attributes)) {
|
|
3386
|
+
return;
|
|
3387
|
+
}
|
|
3388
|
+
const count = countMeaningfulChildren(node.children);
|
|
3389
|
+
if (count <= 1) {
|
|
3390
|
+
context.report({
|
|
3391
|
+
node,
|
|
3392
|
+
messageId: "redundantFragment",
|
|
3393
|
+
data: { count: String(count) }
|
|
3394
|
+
});
|
|
3395
|
+
}
|
|
3396
|
+
}
|
|
3397
|
+
};
|
|
3398
|
+
}
|
|
3399
|
+
});
|
|
3400
|
+
var no_redundant_fragment_default = noRedundantFragment;
|
|
3401
|
+
|
|
2825
3402
|
// src/rules/no-relative-imports.ts
|
|
2826
|
-
var
|
|
2827
|
-
var
|
|
3403
|
+
var import_utils51 = require("@typescript-eslint/utils");
|
|
3404
|
+
var createRule43 = import_utils51.ESLintUtils.RuleCreator(
|
|
2828
3405
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2829
3406
|
);
|
|
2830
|
-
var noRelativeImports =
|
|
3407
|
+
var noRelativeImports = createRule43({
|
|
2831
3408
|
name: "no-relative-imports",
|
|
2832
3409
|
meta: {
|
|
2833
3410
|
type: "suggestion",
|
|
@@ -2851,22 +3428,22 @@ var noRelativeImports = createRule37({
|
|
|
2851
3428
|
};
|
|
2852
3429
|
return {
|
|
2853
3430
|
ImportDeclaration(node) {
|
|
2854
|
-
if (node.source.type ===
|
|
3431
|
+
if (node.source.type === import_utils51.AST_NODE_TYPES.Literal && typeof node.source.value === "string") {
|
|
2855
3432
|
checkImportPath(node.source.value, node);
|
|
2856
3433
|
}
|
|
2857
3434
|
},
|
|
2858
3435
|
ImportExpression(node) {
|
|
2859
|
-
if (node.source.type ===
|
|
3436
|
+
if (node.source.type === import_utils51.AST_NODE_TYPES.Literal && typeof node.source.value === "string") {
|
|
2860
3437
|
checkImportPath(node.source.value, node);
|
|
2861
3438
|
}
|
|
2862
3439
|
},
|
|
2863
3440
|
ExportNamedDeclaration(node) {
|
|
2864
|
-
if (node.source?.type ===
|
|
3441
|
+
if (node.source?.type === import_utils51.AST_NODE_TYPES.Literal && typeof node.source.value === "string") {
|
|
2865
3442
|
checkImportPath(node.source.value, node);
|
|
2866
3443
|
}
|
|
2867
3444
|
},
|
|
2868
3445
|
ExportAllDeclaration(node) {
|
|
2869
|
-
if (node.source.type ===
|
|
3446
|
+
if (node.source.type === import_utils51.AST_NODE_TYPES.Literal && typeof node.source.value === "string") {
|
|
2870
3447
|
checkImportPath(node.source.value, node);
|
|
2871
3448
|
}
|
|
2872
3449
|
}
|
|
@@ -2876,8 +3453,8 @@ var noRelativeImports = createRule37({
|
|
|
2876
3453
|
var no_relative_imports_default = noRelativeImports;
|
|
2877
3454
|
|
|
2878
3455
|
// src/rules/no-single-char-variables.ts
|
|
2879
|
-
var
|
|
2880
|
-
var
|
|
3456
|
+
var import_utils52 = require("@typescript-eslint/utils");
|
|
3457
|
+
var createRule44 = import_utils52.ESLintUtils.RuleCreator(
|
|
2881
3458
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2882
3459
|
);
|
|
2883
3460
|
var ALLOWED_IN_FOR_LOOPS = /* @__PURE__ */ new Set(["i", "j", "k", "n"]);
|
|
@@ -2889,7 +3466,7 @@ var isForLoopInit = (node) => {
|
|
|
2889
3466
|
if (!parentNode) {
|
|
2890
3467
|
return false;
|
|
2891
3468
|
}
|
|
2892
|
-
if (parentNode.type ===
|
|
3469
|
+
if (parentNode.type === import_utils52.AST_NODE_TYPES.ForStatement) {
|
|
2893
3470
|
const { init } = parentNode;
|
|
2894
3471
|
if (init && init === current) {
|
|
2895
3472
|
return true;
|
|
@@ -2908,7 +3485,7 @@ var isAllowedInContext = (name, node) => {
|
|
|
2908
3485
|
}
|
|
2909
3486
|
return false;
|
|
2910
3487
|
};
|
|
2911
|
-
var noSingleCharVariables =
|
|
3488
|
+
var noSingleCharVariables = createRule44({
|
|
2912
3489
|
name: "no-single-char-variables",
|
|
2913
3490
|
meta: {
|
|
2914
3491
|
type: "suggestion",
|
|
@@ -2937,27 +3514,27 @@ var noSingleCharVariables = createRule38({
|
|
|
2937
3514
|
});
|
|
2938
3515
|
};
|
|
2939
3516
|
const checkPattern = (pattern, declarationNode) => {
|
|
2940
|
-
if (pattern.type ===
|
|
3517
|
+
if (pattern.type === import_utils52.AST_NODE_TYPES.Identifier) {
|
|
2941
3518
|
checkIdentifier(pattern, declarationNode);
|
|
2942
|
-
} else if (pattern.type ===
|
|
3519
|
+
} else if (pattern.type === import_utils52.AST_NODE_TYPES.ObjectPattern) {
|
|
2943
3520
|
pattern.properties.forEach((prop) => {
|
|
2944
|
-
if (prop.type ===
|
|
3521
|
+
if (prop.type === import_utils52.AST_NODE_TYPES.Property && prop.value.type === import_utils52.AST_NODE_TYPES.Identifier) {
|
|
2945
3522
|
checkIdentifier(prop.value, declarationNode);
|
|
2946
|
-
} else if (prop.type ===
|
|
3523
|
+
} else if (prop.type === import_utils52.AST_NODE_TYPES.RestElement && prop.argument.type === import_utils52.AST_NODE_TYPES.Identifier) {
|
|
2947
3524
|
checkIdentifier(prop.argument, declarationNode);
|
|
2948
3525
|
}
|
|
2949
3526
|
});
|
|
2950
|
-
} else if (pattern.type ===
|
|
3527
|
+
} else if (pattern.type === import_utils52.AST_NODE_TYPES.ArrayPattern) {
|
|
2951
3528
|
pattern.elements.forEach((element) => {
|
|
2952
|
-
if (element?.type ===
|
|
3529
|
+
if (element?.type === import_utils52.AST_NODE_TYPES.Identifier) {
|
|
2953
3530
|
checkIdentifier(element, declarationNode);
|
|
2954
|
-
} else if (element?.type ===
|
|
3531
|
+
} else if (element?.type === import_utils52.AST_NODE_TYPES.RestElement && element.argument.type === import_utils52.AST_NODE_TYPES.Identifier) {
|
|
2955
3532
|
checkIdentifier(element.argument, declarationNode);
|
|
2956
3533
|
}
|
|
2957
3534
|
});
|
|
2958
|
-
} else if (pattern.type ===
|
|
3535
|
+
} else if (pattern.type === import_utils52.AST_NODE_TYPES.AssignmentPattern && pattern.left.type === import_utils52.AST_NODE_TYPES.Identifier) {
|
|
2959
3536
|
checkIdentifier(pattern.left, declarationNode);
|
|
2960
|
-
} else if (pattern.type ===
|
|
3537
|
+
} else if (pattern.type === import_utils52.AST_NODE_TYPES.RestElement && pattern.argument.type === import_utils52.AST_NODE_TYPES.Identifier) {
|
|
2961
3538
|
checkIdentifier(pattern.argument, declarationNode);
|
|
2962
3539
|
}
|
|
2963
3540
|
};
|
|
@@ -2991,11 +3568,11 @@ var noSingleCharVariables = createRule38({
|
|
|
2991
3568
|
var no_single_char_variables_default = noSingleCharVariables;
|
|
2992
3569
|
|
|
2993
3570
|
// src/rules/prefer-async-await.ts
|
|
2994
|
-
var
|
|
2995
|
-
var
|
|
3571
|
+
var import_utils53 = require("@typescript-eslint/utils");
|
|
3572
|
+
var createRule45 = import_utils53.ESLintUtils.RuleCreator(
|
|
2996
3573
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2997
3574
|
);
|
|
2998
|
-
var preferAsyncAwait =
|
|
3575
|
+
var preferAsyncAwait = createRule45({
|
|
2999
3576
|
name: "prefer-async-await",
|
|
3000
3577
|
meta: {
|
|
3001
3578
|
type: "suggestion",
|
|
@@ -3011,7 +3588,7 @@ var preferAsyncAwait = createRule39({
|
|
|
3011
3588
|
create(context) {
|
|
3012
3589
|
return {
|
|
3013
3590
|
CallExpression(node) {
|
|
3014
|
-
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") {
|
|
3015
3592
|
context.report({
|
|
3016
3593
|
node: node.callee.property,
|
|
3017
3594
|
messageId: "preferAsyncAwait"
|
|
@@ -3024,11 +3601,11 @@ var preferAsyncAwait = createRule39({
|
|
|
3024
3601
|
var prefer_async_await_default = preferAsyncAwait;
|
|
3025
3602
|
|
|
3026
3603
|
// src/rules/prefer-destructuring-params.ts
|
|
3027
|
-
var
|
|
3028
|
-
var
|
|
3604
|
+
var import_utils54 = require("@typescript-eslint/utils");
|
|
3605
|
+
var createRule46 = import_utils54.ESLintUtils.RuleCreator(
|
|
3029
3606
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3030
3607
|
);
|
|
3031
|
-
var preferDestructuringParams =
|
|
3608
|
+
var preferDestructuringParams = createRule46({
|
|
3032
3609
|
name: "prefer-destructuring-params",
|
|
3033
3610
|
meta: {
|
|
3034
3611
|
type: "suggestion",
|
|
@@ -3044,18 +3621,18 @@ var preferDestructuringParams = createRule40({
|
|
|
3044
3621
|
create(context) {
|
|
3045
3622
|
const isCallbackFunction2 = (node) => {
|
|
3046
3623
|
const { parent } = node;
|
|
3047
|
-
return parent?.type ===
|
|
3624
|
+
return parent?.type === import_utils54.AST_NODE_TYPES.CallExpression;
|
|
3048
3625
|
};
|
|
3049
3626
|
const isDeveloperFunction = (node) => {
|
|
3050
|
-
if (node.type ===
|
|
3627
|
+
if (node.type === import_utils54.AST_NODE_TYPES.FunctionDeclaration) {
|
|
3051
3628
|
return true;
|
|
3052
3629
|
}
|
|
3053
|
-
if (node.type ===
|
|
3630
|
+
if (node.type === import_utils54.AST_NODE_TYPES.FunctionExpression || node.type === import_utils54.AST_NODE_TYPES.ArrowFunctionExpression) {
|
|
3054
3631
|
if (isCallbackFunction2(node)) {
|
|
3055
3632
|
return false;
|
|
3056
3633
|
}
|
|
3057
3634
|
const { parent } = node;
|
|
3058
|
-
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;
|
|
3059
3636
|
}
|
|
3060
3637
|
return false;
|
|
3061
3638
|
};
|
|
@@ -3067,7 +3644,7 @@ var preferDestructuringParams = createRule40({
|
|
|
3067
3644
|
if (!isDeveloperFunction(node)) {
|
|
3068
3645
|
return;
|
|
3069
3646
|
}
|
|
3070
|
-
if (node.type ===
|
|
3647
|
+
if (node.type === import_utils54.AST_NODE_TYPES.FunctionDeclaration && node.id) {
|
|
3071
3648
|
const functionName = node.id.name;
|
|
3072
3649
|
if (functionName.startsWith("_") || functionName.includes("$") || /^[A-Z][a-zA-Z]*$/.test(functionName)) {
|
|
3073
3650
|
return;
|
|
@@ -3077,7 +3654,7 @@ var preferDestructuringParams = createRule40({
|
|
|
3077
3654
|
return;
|
|
3078
3655
|
}
|
|
3079
3656
|
const hasNonDestructuredParams = node.params.some(
|
|
3080
|
-
(param) => param.type !==
|
|
3657
|
+
(param) => param.type !== import_utils54.AST_NODE_TYPES.ObjectPattern && param.type !== import_utils54.AST_NODE_TYPES.RestElement
|
|
3081
3658
|
);
|
|
3082
3659
|
if (hasNonDestructuredParams) {
|
|
3083
3660
|
context.report({
|
|
@@ -3096,8 +3673,8 @@ var preferDestructuringParams = createRule40({
|
|
|
3096
3673
|
var prefer_destructuring_params_default = preferDestructuringParams;
|
|
3097
3674
|
|
|
3098
3675
|
// src/rules/prefer-function-declaration.ts
|
|
3099
|
-
var
|
|
3100
|
-
var
|
|
3676
|
+
var import_utils55 = require("@typescript-eslint/utils");
|
|
3677
|
+
var createRule47 = import_utils55.ESLintUtils.RuleCreator(
|
|
3101
3678
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3102
3679
|
);
|
|
3103
3680
|
var isTsFile = (filename) => filename.endsWith(".ts") && !filename.endsWith(".d.ts");
|
|
@@ -3106,33 +3683,33 @@ var isCallbackContext = (node) => {
|
|
|
3106
3683
|
if (!parent) {
|
|
3107
3684
|
return false;
|
|
3108
3685
|
}
|
|
3109
|
-
if (parent.type ===
|
|
3686
|
+
if (parent.type === import_utils55.AST_NODE_TYPES.CallExpression && parent.arguments.includes(node)) {
|
|
3110
3687
|
return true;
|
|
3111
3688
|
}
|
|
3112
|
-
if (parent.type ===
|
|
3689
|
+
if (parent.type === import_utils55.AST_NODE_TYPES.NewExpression && parent.arguments.includes(node)) {
|
|
3113
3690
|
return true;
|
|
3114
3691
|
}
|
|
3115
|
-
if (parent.type ===
|
|
3692
|
+
if (parent.type === import_utils55.AST_NODE_TYPES.ReturnStatement) {
|
|
3116
3693
|
return true;
|
|
3117
3694
|
}
|
|
3118
|
-
if (parent.type ===
|
|
3695
|
+
if (parent.type === import_utils55.AST_NODE_TYPES.Property) {
|
|
3119
3696
|
return true;
|
|
3120
3697
|
}
|
|
3121
|
-
if (parent.type ===
|
|
3698
|
+
if (parent.type === import_utils55.AST_NODE_TYPES.ArrayExpression) {
|
|
3122
3699
|
return true;
|
|
3123
3700
|
}
|
|
3124
|
-
if (parent.type ===
|
|
3701
|
+
if (parent.type === import_utils55.AST_NODE_TYPES.ConditionalExpression) {
|
|
3125
3702
|
return true;
|
|
3126
3703
|
}
|
|
3127
|
-
if (parent.type ===
|
|
3704
|
+
if (parent.type === import_utils55.AST_NODE_TYPES.LogicalExpression) {
|
|
3128
3705
|
return true;
|
|
3129
3706
|
}
|
|
3130
|
-
if (parent.type ===
|
|
3707
|
+
if (parent.type === import_utils55.AST_NODE_TYPES.AssignmentExpression && parent.left !== node) {
|
|
3131
3708
|
return true;
|
|
3132
3709
|
}
|
|
3133
3710
|
return false;
|
|
3134
3711
|
};
|
|
3135
|
-
var preferFunctionDeclaration =
|
|
3712
|
+
var preferFunctionDeclaration = createRule47({
|
|
3136
3713
|
name: "prefer-function-declaration",
|
|
3137
3714
|
meta: {
|
|
3138
3715
|
type: "suggestion",
|
|
@@ -3153,14 +3730,14 @@ var preferFunctionDeclaration = createRule41({
|
|
|
3153
3730
|
}
|
|
3154
3731
|
return {
|
|
3155
3732
|
VariableDeclarator(node) {
|
|
3156
|
-
if (node.id.type !==
|
|
3733
|
+
if (node.id.type !== import_utils55.AST_NODE_TYPES.Identifier) {
|
|
3157
3734
|
return;
|
|
3158
3735
|
}
|
|
3159
3736
|
const { init } = node;
|
|
3160
3737
|
if (!init) {
|
|
3161
3738
|
return;
|
|
3162
3739
|
}
|
|
3163
|
-
if (init.type ===
|
|
3740
|
+
if (init.type === import_utils55.AST_NODE_TYPES.ArrowFunctionExpression) {
|
|
3164
3741
|
if (isCallbackContext(init)) {
|
|
3165
3742
|
return;
|
|
3166
3743
|
}
|
|
@@ -3170,7 +3747,7 @@ var preferFunctionDeclaration = createRule41({
|
|
|
3170
3747
|
data: { name: node.id.name }
|
|
3171
3748
|
});
|
|
3172
3749
|
}
|
|
3173
|
-
if (init.type ===
|
|
3750
|
+
if (init.type === import_utils55.AST_NODE_TYPES.FunctionExpression) {
|
|
3174
3751
|
if (isCallbackContext(init)) {
|
|
3175
3752
|
return;
|
|
3176
3753
|
}
|
|
@@ -3187,11 +3764,11 @@ var preferFunctionDeclaration = createRule41({
|
|
|
3187
3764
|
var prefer_function_declaration_default = preferFunctionDeclaration;
|
|
3188
3765
|
|
|
3189
3766
|
// src/rules/prefer-guard-clause.ts
|
|
3190
|
-
var
|
|
3191
|
-
var
|
|
3767
|
+
var import_utils56 = require("@typescript-eslint/utils");
|
|
3768
|
+
var createRule48 = import_utils56.ESLintUtils.RuleCreator(
|
|
3192
3769
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3193
3770
|
);
|
|
3194
|
-
var preferGuardClause =
|
|
3771
|
+
var preferGuardClause = createRule48({
|
|
3195
3772
|
name: "prefer-guard-clause",
|
|
3196
3773
|
meta: {
|
|
3197
3774
|
type: "suggestion",
|
|
@@ -3208,8 +3785,8 @@ var preferGuardClause = createRule42({
|
|
|
3208
3785
|
return {
|
|
3209
3786
|
IfStatement(node) {
|
|
3210
3787
|
const { consequent } = node;
|
|
3211
|
-
if (consequent.type ===
|
|
3212
|
-
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);
|
|
3213
3790
|
if (hasNestedIf && consequent.body.length === 1) {
|
|
3214
3791
|
context.report({
|
|
3215
3792
|
node,
|
|
@@ -3217,7 +3794,7 @@ var preferGuardClause = createRule42({
|
|
|
3217
3794
|
});
|
|
3218
3795
|
}
|
|
3219
3796
|
}
|
|
3220
|
-
if (consequent.type ===
|
|
3797
|
+
if (consequent.type === import_utils56.AST_NODE_TYPES.IfStatement) {
|
|
3221
3798
|
context.report({
|
|
3222
3799
|
node,
|
|
3223
3800
|
messageId: "preferGuardClause"
|
|
@@ -3230,11 +3807,11 @@ var preferGuardClause = createRule42({
|
|
|
3230
3807
|
var prefer_guard_clause_default = preferGuardClause;
|
|
3231
3808
|
|
|
3232
3809
|
// src/rules/prefer-import-type.ts
|
|
3233
|
-
var
|
|
3234
|
-
var
|
|
3810
|
+
var import_utils57 = require("@typescript-eslint/utils");
|
|
3811
|
+
var createRule49 = import_utils57.ESLintUtils.RuleCreator(
|
|
3235
3812
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3236
3813
|
);
|
|
3237
|
-
var preferImportType =
|
|
3814
|
+
var preferImportType = createRule49({
|
|
3238
3815
|
name: "prefer-import-type",
|
|
3239
3816
|
meta: {
|
|
3240
3817
|
type: "suggestion",
|
|
@@ -3253,22 +3830,22 @@ var preferImportType = createRule43({
|
|
|
3253
3830
|
let current = node;
|
|
3254
3831
|
while (current) {
|
|
3255
3832
|
switch (current.type) {
|
|
3256
|
-
case
|
|
3257
|
-
case
|
|
3258
|
-
case
|
|
3259
|
-
case
|
|
3260
|
-
case
|
|
3261
|
-
case
|
|
3262
|
-
case
|
|
3263
|
-
case
|
|
3264
|
-
case
|
|
3265
|
-
case
|
|
3266
|
-
case
|
|
3267
|
-
case
|
|
3268
|
-
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:
|
|
3269
3846
|
return true;
|
|
3270
|
-
case
|
|
3271
|
-
case
|
|
3847
|
+
case import_utils57.AST_NODE_TYPES.MemberExpression:
|
|
3848
|
+
case import_utils57.AST_NODE_TYPES.Identifier:
|
|
3272
3849
|
current = current.parent;
|
|
3273
3850
|
break;
|
|
3274
3851
|
default:
|
|
@@ -3298,27 +3875,27 @@ var preferImportType = createRule43({
|
|
|
3298
3875
|
return false;
|
|
3299
3876
|
}
|
|
3300
3877
|
switch (parent.type) {
|
|
3301
|
-
case
|
|
3302
|
-
case
|
|
3303
|
-
case
|
|
3304
|
-
case
|
|
3305
|
-
case
|
|
3306
|
-
case
|
|
3307
|
-
case
|
|
3308
|
-
case
|
|
3309
|
-
case
|
|
3310
|
-
case
|
|
3311
|
-
case
|
|
3312
|
-
case
|
|
3313
|
-
case
|
|
3314
|
-
case
|
|
3315
|
-
case
|
|
3316
|
-
case
|
|
3317
|
-
case
|
|
3318
|
-
case
|
|
3319
|
-
case
|
|
3320
|
-
case
|
|
3321
|
-
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:
|
|
3322
3899
|
return true;
|
|
3323
3900
|
default:
|
|
3324
3901
|
return false;
|
|
@@ -3330,7 +3907,7 @@ var preferImportType = createRule43({
|
|
|
3330
3907
|
return;
|
|
3331
3908
|
}
|
|
3332
3909
|
const hasInlineTypeSpecifier = node.specifiers.some(
|
|
3333
|
-
(specifier) => specifier.type ===
|
|
3910
|
+
(specifier) => specifier.type === import_utils57.AST_NODE_TYPES.ImportSpecifier && specifier.importKind === "type"
|
|
3334
3911
|
);
|
|
3335
3912
|
if (hasInlineTypeSpecifier) {
|
|
3336
3913
|
return;
|
|
@@ -3348,13 +3925,13 @@ var preferImportType = createRule43({
|
|
|
3348
3925
|
}
|
|
3349
3926
|
const scope = context.sourceCode.getScope(node);
|
|
3350
3927
|
const isTypeOnlyImport2 = node.specifiers.every((specifier) => {
|
|
3351
|
-
if (specifier.type ===
|
|
3928
|
+
if (specifier.type === import_utils57.AST_NODE_TYPES.ImportDefaultSpecifier) {
|
|
3352
3929
|
return false;
|
|
3353
3930
|
}
|
|
3354
|
-
if (specifier.type ===
|
|
3931
|
+
if (specifier.type === import_utils57.AST_NODE_TYPES.ImportNamespaceSpecifier) {
|
|
3355
3932
|
return false;
|
|
3356
3933
|
}
|
|
3357
|
-
if (specifier.type ===
|
|
3934
|
+
if (specifier.type === import_utils57.AST_NODE_TYPES.ImportSpecifier) {
|
|
3358
3935
|
const localName = specifier.local.name;
|
|
3359
3936
|
return !isUsedAsValue(localName, scope);
|
|
3360
3937
|
}
|
|
@@ -3380,19 +3957,19 @@ var preferImportType = createRule43({
|
|
|
3380
3957
|
var prefer_import_type_default = preferImportType;
|
|
3381
3958
|
|
|
3382
3959
|
// src/rules/prefer-inline-literal-union.ts
|
|
3383
|
-
var
|
|
3384
|
-
var
|
|
3960
|
+
var import_utils58 = require("@typescript-eslint/utils");
|
|
3961
|
+
var createRule50 = import_utils58.ESLintUtils.RuleCreator(
|
|
3385
3962
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3386
3963
|
);
|
|
3387
3964
|
function isLiteralUnionType(node) {
|
|
3388
|
-
if (node.type !==
|
|
3965
|
+
if (node.type !== import_utils58.AST_NODE_TYPES.TSUnionType) {
|
|
3389
3966
|
return false;
|
|
3390
3967
|
}
|
|
3391
3968
|
return node.types.every(
|
|
3392
|
-
(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
|
|
3393
3970
|
);
|
|
3394
3971
|
}
|
|
3395
|
-
var preferInlineLiteralUnion =
|
|
3972
|
+
var preferInlineLiteralUnion = createRule50({
|
|
3396
3973
|
name: "prefer-inline-literal-union",
|
|
3397
3974
|
meta: {
|
|
3398
3975
|
type: "suggestion",
|
|
@@ -3419,10 +3996,10 @@ var preferInlineLiteralUnion = createRule44({
|
|
|
3419
3996
|
return;
|
|
3420
3997
|
}
|
|
3421
3998
|
const { typeAnnotation } = node.typeAnnotation;
|
|
3422
|
-
if (typeAnnotation.type !==
|
|
3999
|
+
if (typeAnnotation.type !== import_utils58.AST_NODE_TYPES.TSTypeReference) {
|
|
3423
4000
|
return;
|
|
3424
4001
|
}
|
|
3425
|
-
if (typeAnnotation.typeName.type !==
|
|
4002
|
+
if (typeAnnotation.typeName.type !== import_utils58.AST_NODE_TYPES.Identifier) {
|
|
3426
4003
|
return;
|
|
3427
4004
|
}
|
|
3428
4005
|
const aliasName = typeAnnotation.typeName.name;
|
|
@@ -3446,12 +4023,12 @@ var preferInlineLiteralUnion = createRule44({
|
|
|
3446
4023
|
var prefer_inline_literal_union_default = preferInlineLiteralUnion;
|
|
3447
4024
|
|
|
3448
4025
|
// src/rules/prefer-inline-type-export.ts
|
|
3449
|
-
var
|
|
3450
|
-
var
|
|
4026
|
+
var import_utils59 = require("@typescript-eslint/utils");
|
|
4027
|
+
var createRule51 = import_utils59.ESLintUtils.RuleCreator(
|
|
3451
4028
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3452
4029
|
);
|
|
3453
|
-
var isTypeDeclaration = (node) => node.type ===
|
|
3454
|
-
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({
|
|
3455
4032
|
name: "prefer-inline-type-export",
|
|
3456
4033
|
meta: {
|
|
3457
4034
|
type: "suggestion",
|
|
@@ -3468,12 +4045,12 @@ var preferInlineTypeExport = createRule45({
|
|
|
3468
4045
|
create(context) {
|
|
3469
4046
|
const typeDeclarations = /* @__PURE__ */ new Map();
|
|
3470
4047
|
function collectDeclaration(node) {
|
|
3471
|
-
if (node.parent.type !==
|
|
4048
|
+
if (node.parent.type !== import_utils59.AST_NODE_TYPES.ExportNamedDeclaration) {
|
|
3472
4049
|
typeDeclarations.set(node.id.name, node);
|
|
3473
4050
|
}
|
|
3474
4051
|
}
|
|
3475
4052
|
function reportSpecifier(specifier, statement, declarationNode) {
|
|
3476
|
-
if (specifier.local.type !==
|
|
4053
|
+
if (specifier.local.type !== import_utils59.AST_NODE_TYPES.Identifier) {
|
|
3477
4054
|
return;
|
|
3478
4055
|
}
|
|
3479
4056
|
const { name } = specifier.local;
|
|
@@ -3506,16 +4083,16 @@ var preferInlineTypeExport = createRule45({
|
|
|
3506
4083
|
return {
|
|
3507
4084
|
Program(node) {
|
|
3508
4085
|
node.body.forEach((statement) => {
|
|
3509
|
-
if (statement.type ===
|
|
4086
|
+
if (statement.type === import_utils59.AST_NODE_TYPES.TSInterfaceDeclaration || statement.type === import_utils59.AST_NODE_TYPES.TSTypeAliasDeclaration) {
|
|
3510
4087
|
collectDeclaration(statement);
|
|
3511
4088
|
}
|
|
3512
4089
|
});
|
|
3513
4090
|
node.body.forEach((statement) => {
|
|
3514
|
-
if (statement.type !==
|
|
4091
|
+
if (statement.type !== import_utils59.AST_NODE_TYPES.ExportNamedDeclaration || statement.declaration !== null) {
|
|
3515
4092
|
return;
|
|
3516
4093
|
}
|
|
3517
4094
|
statement.specifiers.forEach((specifier) => {
|
|
3518
|
-
if (specifier.local.type !==
|
|
4095
|
+
if (specifier.local.type !== import_utils59.AST_NODE_TYPES.Identifier) {
|
|
3519
4096
|
return;
|
|
3520
4097
|
}
|
|
3521
4098
|
const declarationNode = typeDeclarations.get(specifier.local.name);
|
|
@@ -3532,11 +4109,11 @@ var preferInlineTypeExport = createRule45({
|
|
|
3532
4109
|
var prefer_inline_type_export_default = preferInlineTypeExport;
|
|
3533
4110
|
|
|
3534
4111
|
// src/rules/prefer-interface-for-component-props.ts
|
|
3535
|
-
var
|
|
3536
|
-
var
|
|
4112
|
+
var import_utils60 = require("@typescript-eslint/utils");
|
|
4113
|
+
var createRule52 = import_utils60.ESLintUtils.RuleCreator(
|
|
3537
4114
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3538
4115
|
);
|
|
3539
|
-
var preferInterfaceForComponentProps =
|
|
4116
|
+
var preferInterfaceForComponentProps = createRule52({
|
|
3540
4117
|
name: "prefer-interface-for-component-props",
|
|
3541
4118
|
meta: {
|
|
3542
4119
|
type: "suggestion",
|
|
@@ -3556,13 +4133,13 @@ var preferInterfaceForComponentProps = createRule46({
|
|
|
3556
4133
|
}
|
|
3557
4134
|
return {
|
|
3558
4135
|
TSTypeAliasDeclaration(node) {
|
|
3559
|
-
if (node.id.type !==
|
|
4136
|
+
if (node.id.type !== import_utils60.AST_NODE_TYPES.Identifier) {
|
|
3560
4137
|
return;
|
|
3561
4138
|
}
|
|
3562
4139
|
if (!node.id.name.endsWith("Props")) {
|
|
3563
4140
|
return;
|
|
3564
4141
|
}
|
|
3565
|
-
if (node.typeAnnotation.type !==
|
|
4142
|
+
if (node.typeAnnotation.type !== import_utils60.AST_NODE_TYPES.TSTypeLiteral) {
|
|
3566
4143
|
return;
|
|
3567
4144
|
}
|
|
3568
4145
|
const { name } = node.id;
|
|
@@ -3589,11 +4166,11 @@ var preferInterfaceForComponentProps = createRule46({
|
|
|
3589
4166
|
var prefer_interface_for_component_props_default = preferInterfaceForComponentProps;
|
|
3590
4167
|
|
|
3591
4168
|
// src/rules/prefer-interface-over-inline-types.ts
|
|
3592
|
-
var
|
|
3593
|
-
var
|
|
4169
|
+
var import_utils62 = require("@typescript-eslint/utils");
|
|
4170
|
+
var createRule53 = import_utils62.ESLintUtils.RuleCreator(
|
|
3594
4171
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3595
4172
|
);
|
|
3596
|
-
var preferInterfaceOverInlineTypes =
|
|
4173
|
+
var preferInterfaceOverInlineTypes = createRule53({
|
|
3597
4174
|
name: "prefer-interface-over-inline-types",
|
|
3598
4175
|
meta: {
|
|
3599
4176
|
type: "suggestion",
|
|
@@ -3609,54 +4186,54 @@ var preferInterfaceOverInlineTypes = createRule47({
|
|
|
3609
4186
|
defaultOptions: [],
|
|
3610
4187
|
create(context) {
|
|
3611
4188
|
function hasJSXInConditional(node) {
|
|
3612
|
-
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;
|
|
3613
4190
|
}
|
|
3614
4191
|
function hasJSXInLogical(node) {
|
|
3615
|
-
return node.right.type ===
|
|
4192
|
+
return node.right.type === import_utils62.AST_NODE_TYPES.JSXElement || node.right.type === import_utils62.AST_NODE_TYPES.JSXFragment;
|
|
3616
4193
|
}
|
|
3617
4194
|
function hasJSXReturn(block) {
|
|
3618
4195
|
return block.body.some((stmt) => {
|
|
3619
|
-
if (stmt.type ===
|
|
3620
|
-
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);
|
|
3621
4198
|
}
|
|
3622
4199
|
return false;
|
|
3623
4200
|
});
|
|
3624
4201
|
}
|
|
3625
4202
|
function isReactComponent2(node) {
|
|
3626
|
-
if (node.type ===
|
|
3627
|
-
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) {
|
|
3628
4205
|
return true;
|
|
3629
4206
|
}
|
|
3630
|
-
if (node.body.type ===
|
|
4207
|
+
if (node.body.type === import_utils62.AST_NODE_TYPES.BlockStatement) {
|
|
3631
4208
|
return hasJSXReturn(node.body);
|
|
3632
4209
|
}
|
|
3633
|
-
} else if (node.type ===
|
|
3634
|
-
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) {
|
|
3635
4212
|
return hasJSXReturn(node.body);
|
|
3636
4213
|
}
|
|
3637
4214
|
}
|
|
3638
4215
|
return false;
|
|
3639
4216
|
}
|
|
3640
4217
|
function isInlineTypeAnnotation(node) {
|
|
3641
|
-
if (node.type ===
|
|
4218
|
+
if (node.type === import_utils62.AST_NODE_TYPES.TSTypeLiteral) {
|
|
3642
4219
|
return true;
|
|
3643
4220
|
}
|
|
3644
|
-
if (node.type ===
|
|
3645
|
-
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);
|
|
3646
4223
|
}
|
|
3647
|
-
if (node.type ===
|
|
4224
|
+
if (node.type === import_utils62.AST_NODE_TYPES.TSUnionType) {
|
|
3648
4225
|
return node.types.some((type) => isInlineTypeAnnotation(type));
|
|
3649
4226
|
}
|
|
3650
4227
|
return false;
|
|
3651
4228
|
}
|
|
3652
4229
|
function hasInlineObjectType(node) {
|
|
3653
|
-
if (node.type ===
|
|
4230
|
+
if (node.type === import_utils62.AST_NODE_TYPES.TSTypeLiteral) {
|
|
3654
4231
|
return true;
|
|
3655
4232
|
}
|
|
3656
|
-
if (node.type ===
|
|
3657
|
-
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);
|
|
3658
4235
|
}
|
|
3659
|
-
if (node.type ===
|
|
4236
|
+
if (node.type === import_utils62.AST_NODE_TYPES.TSUnionType) {
|
|
3660
4237
|
return node.types.some((type) => hasInlineObjectType(type));
|
|
3661
4238
|
}
|
|
3662
4239
|
return false;
|
|
@@ -3669,7 +4246,7 @@ var preferInterfaceOverInlineTypes = createRule47({
|
|
|
3669
4246
|
return;
|
|
3670
4247
|
}
|
|
3671
4248
|
const param = node.params[0];
|
|
3672
|
-
if (param.type ===
|
|
4249
|
+
if (param.type === import_utils62.AST_NODE_TYPES.Identifier && param.typeAnnotation) {
|
|
3673
4250
|
const { typeAnnotation } = param.typeAnnotation;
|
|
3674
4251
|
if (isInlineTypeAnnotation(typeAnnotation) && hasInlineObjectType(typeAnnotation)) {
|
|
3675
4252
|
context.report({
|
|
@@ -3689,11 +4266,11 @@ var preferInterfaceOverInlineTypes = createRule47({
|
|
|
3689
4266
|
var prefer_interface_over_inline_types_default = preferInterfaceOverInlineTypes;
|
|
3690
4267
|
|
|
3691
4268
|
// src/rules/prefer-jsx-template-literals.ts
|
|
3692
|
-
var
|
|
3693
|
-
var
|
|
4269
|
+
var import_utils63 = require("@typescript-eslint/utils");
|
|
4270
|
+
var createRule54 = import_utils63.ESLintUtils.RuleCreator(
|
|
3694
4271
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3695
4272
|
);
|
|
3696
|
-
var preferJSXTemplateLiterals =
|
|
4273
|
+
var preferJSXTemplateLiterals = createRule54({
|
|
3697
4274
|
name: "prefer-jsx-template-literals",
|
|
3698
4275
|
meta: {
|
|
3699
4276
|
type: "suggestion",
|
|
@@ -3762,9 +4339,9 @@ var preferJSXTemplateLiterals = createRule48({
|
|
|
3762
4339
|
if (!child || !nextChild) {
|
|
3763
4340
|
return;
|
|
3764
4341
|
}
|
|
3765
|
-
if (child.type ===
|
|
4342
|
+
if (child.type === import_utils63.AST_NODE_TYPES.JSXText && nextChild.type === import_utils63.AST_NODE_TYPES.JSXExpressionContainer) {
|
|
3766
4343
|
handleTextBeforeExpression(child, nextChild);
|
|
3767
|
-
} else if (child.type ===
|
|
4344
|
+
} else if (child.type === import_utils63.AST_NODE_TYPES.JSXExpressionContainer && nextChild.type === import_utils63.AST_NODE_TYPES.JSXText) {
|
|
3768
4345
|
handleExpressionBeforeText(child, nextChild);
|
|
3769
4346
|
}
|
|
3770
4347
|
}
|
|
@@ -3777,32 +4354,32 @@ var preferJSXTemplateLiterals = createRule48({
|
|
|
3777
4354
|
var prefer_jsx_template_literals_default = preferJSXTemplateLiterals;
|
|
3778
4355
|
|
|
3779
4356
|
// src/rules/prefer-named-param-types.ts
|
|
3780
|
-
var
|
|
3781
|
-
var
|
|
4357
|
+
var import_utils64 = require("@typescript-eslint/utils");
|
|
4358
|
+
var createRule55 = import_utils64.ESLintUtils.RuleCreator(
|
|
3782
4359
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3783
4360
|
);
|
|
3784
4361
|
var returnsJsx2 = (node) => {
|
|
3785
|
-
if (node.type ===
|
|
4362
|
+
if (node.type === import_utils64.AST_NODE_TYPES.JSXElement || node.type === import_utils64.AST_NODE_TYPES.JSXFragment) {
|
|
3786
4363
|
return true;
|
|
3787
4364
|
}
|
|
3788
|
-
if (node.type ===
|
|
4365
|
+
if (node.type === import_utils64.AST_NODE_TYPES.ConditionalExpression) {
|
|
3789
4366
|
return returnsJsx2(node.consequent) || returnsJsx2(node.alternate);
|
|
3790
4367
|
}
|
|
3791
|
-
if (node.type ===
|
|
4368
|
+
if (node.type === import_utils64.AST_NODE_TYPES.LogicalExpression) {
|
|
3792
4369
|
return returnsJsx2(node.left) || returnsJsx2(node.right);
|
|
3793
4370
|
}
|
|
3794
4371
|
return false;
|
|
3795
4372
|
};
|
|
3796
4373
|
var bodyReturnsJsx2 = (body) => {
|
|
3797
|
-
if (body.type !==
|
|
4374
|
+
if (body.type !== import_utils64.AST_NODE_TYPES.BlockStatement) {
|
|
3798
4375
|
return returnsJsx2(body);
|
|
3799
4376
|
}
|
|
3800
4377
|
return body.body.some(
|
|
3801
|
-
(stmt) => stmt.type ===
|
|
4378
|
+
(stmt) => stmt.type === import_utils64.AST_NODE_TYPES.ReturnStatement && stmt.argument !== null && returnsJsx2(stmt.argument)
|
|
3802
4379
|
);
|
|
3803
4380
|
};
|
|
3804
4381
|
var isReactComponentFunction = (node) => bodyReturnsJsx2(node.body);
|
|
3805
|
-
var preferNamedParamTypes =
|
|
4382
|
+
var preferNamedParamTypes = createRule55({
|
|
3806
4383
|
name: "prefer-named-param-types",
|
|
3807
4384
|
meta: {
|
|
3808
4385
|
type: "suggestion",
|
|
@@ -3817,16 +4394,16 @@ var preferNamedParamTypes = createRule49({
|
|
|
3817
4394
|
defaultOptions: [],
|
|
3818
4395
|
create(context) {
|
|
3819
4396
|
function hasInlineObjectType(param) {
|
|
3820
|
-
if (param.type ===
|
|
4397
|
+
if (param.type === import_utils64.AST_NODE_TYPES.AssignmentPattern) {
|
|
3821
4398
|
return hasInlineObjectType(param.left);
|
|
3822
4399
|
}
|
|
3823
|
-
if (param.type ===
|
|
3824
|
-
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) {
|
|
3825
4402
|
return true;
|
|
3826
4403
|
}
|
|
3827
4404
|
}
|
|
3828
|
-
if (param.type ===
|
|
3829
|
-
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) {
|
|
3830
4407
|
return true;
|
|
3831
4408
|
}
|
|
3832
4409
|
}
|
|
@@ -3839,7 +4416,7 @@ var preferNamedParamTypes = createRule49({
|
|
|
3839
4416
|
} else if ("value" in node && node.value) {
|
|
3840
4417
|
params = node.value.params;
|
|
3841
4418
|
}
|
|
3842
|
-
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)) {
|
|
3843
4420
|
return;
|
|
3844
4421
|
}
|
|
3845
4422
|
params.forEach((param) => {
|
|
@@ -3863,11 +4440,11 @@ var preferNamedParamTypes = createRule49({
|
|
|
3863
4440
|
var prefer_named_param_types_default = preferNamedParamTypes;
|
|
3864
4441
|
|
|
3865
4442
|
// src/rules/prefer-props-with-children.ts
|
|
3866
|
-
var
|
|
3867
|
-
var
|
|
4443
|
+
var import_utils65 = require("@typescript-eslint/utils");
|
|
4444
|
+
var createRule56 = import_utils65.ESLintUtils.RuleCreator(
|
|
3868
4445
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3869
4446
|
);
|
|
3870
|
-
var preferPropsWithChildren =
|
|
4447
|
+
var preferPropsWithChildren = createRule56({
|
|
3871
4448
|
name: "prefer-props-with-children",
|
|
3872
4449
|
meta: {
|
|
3873
4450
|
type: "suggestion",
|
|
@@ -3885,24 +4462,24 @@ var preferPropsWithChildren = createRule50({
|
|
|
3885
4462
|
if (!typeNode) {
|
|
3886
4463
|
return false;
|
|
3887
4464
|
}
|
|
3888
|
-
if (typeNode.type !==
|
|
4465
|
+
if (typeNode.type !== import_utils65.AST_NODE_TYPES.TSTypeReference) {
|
|
3889
4466
|
return false;
|
|
3890
4467
|
}
|
|
3891
4468
|
const { typeName } = typeNode;
|
|
3892
|
-
if (typeName.type ===
|
|
4469
|
+
if (typeName.type === import_utils65.AST_NODE_TYPES.Identifier) {
|
|
3893
4470
|
return typeName.name === "ReactNode";
|
|
3894
4471
|
}
|
|
3895
|
-
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") {
|
|
3896
4473
|
return true;
|
|
3897
4474
|
}
|
|
3898
4475
|
return false;
|
|
3899
4476
|
}
|
|
3900
4477
|
function findChildrenReactNode(members) {
|
|
3901
4478
|
for (const member of members) {
|
|
3902
|
-
if (member.type !==
|
|
4479
|
+
if (member.type !== import_utils65.AST_NODE_TYPES.TSPropertySignature) {
|
|
3903
4480
|
continue;
|
|
3904
4481
|
}
|
|
3905
|
-
if (member.key.type !==
|
|
4482
|
+
if (member.key.type !== import_utils65.AST_NODE_TYPES.Identifier) {
|
|
3906
4483
|
continue;
|
|
3907
4484
|
}
|
|
3908
4485
|
if (member.key.name !== "children") {
|
|
@@ -3942,11 +4519,11 @@ var preferPropsWithChildren = createRule50({
|
|
|
3942
4519
|
var prefer_props_with_children_default = preferPropsWithChildren;
|
|
3943
4520
|
|
|
3944
4521
|
// src/rules/prefer-react-import-types.ts
|
|
3945
|
-
var
|
|
3946
|
-
var
|
|
4522
|
+
var import_utils66 = require("@typescript-eslint/utils");
|
|
4523
|
+
var createRule57 = import_utils66.ESLintUtils.RuleCreator(
|
|
3947
4524
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3948
4525
|
);
|
|
3949
|
-
var preferReactImportTypes =
|
|
4526
|
+
var preferReactImportTypes = createRule57({
|
|
3950
4527
|
name: "prefer-react-import-types",
|
|
3951
4528
|
meta: {
|
|
3952
4529
|
type: "suggestion",
|
|
@@ -4022,7 +4599,7 @@ var preferReactImportTypes = createRule51({
|
|
|
4022
4599
|
]);
|
|
4023
4600
|
const allReactExports = /* @__PURE__ */ new Set([...reactTypes, ...reactRuntimeExports]);
|
|
4024
4601
|
function checkMemberExpression(node) {
|
|
4025
|
-
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)) {
|
|
4026
4603
|
const typeName = node.property.name;
|
|
4027
4604
|
const isType = reactTypes.has(typeName);
|
|
4028
4605
|
const importStatement = isType ? `import type { ${typeName} } from "react"` : `import { ${typeName} } from "react"`;
|
|
@@ -4039,7 +4616,7 @@ var preferReactImportTypes = createRule51({
|
|
|
4039
4616
|
return {
|
|
4040
4617
|
MemberExpression: checkMemberExpression,
|
|
4041
4618
|
"TSTypeReference > TSQualifiedName": (node) => {
|
|
4042
|
-
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)) {
|
|
4043
4620
|
const typeName = node.right.name;
|
|
4044
4621
|
const isType = reactTypes.has(typeName);
|
|
4045
4622
|
const importStatement = isType ? `import type { ${typeName} } from "react"` : `import { ${typeName} } from "react"`;
|
|
@@ -4059,11 +4636,11 @@ var preferReactImportTypes = createRule51({
|
|
|
4059
4636
|
var prefer_react_import_types_default = preferReactImportTypes;
|
|
4060
4637
|
|
|
4061
4638
|
// src/rules/react-props-destructure.ts
|
|
4062
|
-
var
|
|
4063
|
-
var
|
|
4639
|
+
var import_utils67 = require("@typescript-eslint/utils");
|
|
4640
|
+
var createRule58 = import_utils67.ESLintUtils.RuleCreator(
|
|
4064
4641
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
4065
4642
|
);
|
|
4066
|
-
var reactPropsDestructure =
|
|
4643
|
+
var reactPropsDestructure = createRule58({
|
|
4067
4644
|
name: "react-props-destructure",
|
|
4068
4645
|
meta: {
|
|
4069
4646
|
type: "suggestion",
|
|
@@ -4079,29 +4656,29 @@ var reactPropsDestructure = createRule52({
|
|
|
4079
4656
|
defaultOptions: [],
|
|
4080
4657
|
create(context) {
|
|
4081
4658
|
function hasJSXInConditional(node) {
|
|
4082
|
-
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;
|
|
4083
4660
|
}
|
|
4084
4661
|
function hasJSXInLogical(node) {
|
|
4085
|
-
return node.right.type ===
|
|
4662
|
+
return node.right.type === import_utils67.AST_NODE_TYPES.JSXElement || node.right.type === import_utils67.AST_NODE_TYPES.JSXFragment;
|
|
4086
4663
|
}
|
|
4087
4664
|
function hasJSXReturn(block) {
|
|
4088
4665
|
return block.body.some((stmt) => {
|
|
4089
|
-
if (stmt.type ===
|
|
4090
|
-
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);
|
|
4091
4668
|
}
|
|
4092
4669
|
return false;
|
|
4093
4670
|
});
|
|
4094
4671
|
}
|
|
4095
4672
|
function isReactComponent2(node) {
|
|
4096
|
-
if (node.type ===
|
|
4097
|
-
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) {
|
|
4098
4675
|
return true;
|
|
4099
4676
|
}
|
|
4100
|
-
if (node.body.type ===
|
|
4677
|
+
if (node.body.type === import_utils67.AST_NODE_TYPES.BlockStatement) {
|
|
4101
4678
|
return hasJSXReturn(node.body);
|
|
4102
4679
|
}
|
|
4103
|
-
} else if (node.type ===
|
|
4104
|
-
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) {
|
|
4105
4682
|
return hasJSXReturn(node.body);
|
|
4106
4683
|
}
|
|
4107
4684
|
}
|
|
@@ -4115,9 +4692,9 @@ var reactPropsDestructure = createRule52({
|
|
|
4115
4692
|
return;
|
|
4116
4693
|
}
|
|
4117
4694
|
const param = node.params[0];
|
|
4118
|
-
if (param.type ===
|
|
4119
|
-
const properties = param.properties.filter((prop) => prop.type ===
|
|
4120
|
-
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) {
|
|
4121
4698
|
return prop.key.name;
|
|
4122
4699
|
}
|
|
4123
4700
|
return null;
|
|
@@ -4144,57 +4721,57 @@ var reactPropsDestructure = createRule52({
|
|
|
4144
4721
|
var react_props_destructure_default = reactPropsDestructure;
|
|
4145
4722
|
|
|
4146
4723
|
// src/rules/require-explicit-return-type.ts
|
|
4147
|
-
var
|
|
4148
|
-
var
|
|
4724
|
+
var import_utils68 = require("@typescript-eslint/utils");
|
|
4725
|
+
var createRule59 = import_utils68.ESLintUtils.RuleCreator(
|
|
4149
4726
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
4150
4727
|
);
|
|
4151
4728
|
var isReactComponent = (node) => {
|
|
4152
|
-
if (node.type ===
|
|
4729
|
+
if (node.type === import_utils68.AST_NODE_TYPES.ArrowFunctionExpression) {
|
|
4153
4730
|
const { parent } = node;
|
|
4154
|
-
if (parent?.type ===
|
|
4731
|
+
if (parent?.type === import_utils68.AST_NODE_TYPES.VariableDeclarator) {
|
|
4155
4732
|
const { id } = parent;
|
|
4156
|
-
if (id.type ===
|
|
4733
|
+
if (id.type === import_utils68.AST_NODE_TYPES.Identifier) {
|
|
4157
4734
|
return /^[A-Z]/.test(id.name);
|
|
4158
4735
|
}
|
|
4159
4736
|
}
|
|
4160
4737
|
}
|
|
4161
|
-
if (node.type ===
|
|
4738
|
+
if (node.type === import_utils68.AST_NODE_TYPES.FunctionDeclaration && node.id) {
|
|
4162
4739
|
return /^[A-Z]/.test(node.id.name);
|
|
4163
4740
|
}
|
|
4164
4741
|
return false;
|
|
4165
4742
|
};
|
|
4166
4743
|
var isCallbackFunction = (node) => {
|
|
4167
|
-
if (node.type ===
|
|
4744
|
+
if (node.type === import_utils68.AST_NODE_TYPES.FunctionDeclaration) {
|
|
4168
4745
|
return false;
|
|
4169
4746
|
}
|
|
4170
4747
|
const { parent } = node;
|
|
4171
4748
|
if (!parent) {
|
|
4172
4749
|
return false;
|
|
4173
4750
|
}
|
|
4174
|
-
if (parent.type ===
|
|
4751
|
+
if (parent.type === import_utils68.AST_NODE_TYPES.CallExpression && parent.arguments.includes(node)) {
|
|
4175
4752
|
return true;
|
|
4176
4753
|
}
|
|
4177
|
-
if (parent.type ===
|
|
4754
|
+
if (parent.type === import_utils68.AST_NODE_TYPES.Property) {
|
|
4178
4755
|
return true;
|
|
4179
4756
|
}
|
|
4180
|
-
if (parent.type ===
|
|
4757
|
+
if (parent.type === import_utils68.AST_NODE_TYPES.ArrayExpression) {
|
|
4181
4758
|
return true;
|
|
4182
4759
|
}
|
|
4183
4760
|
return false;
|
|
4184
4761
|
};
|
|
4185
4762
|
var getFunctionName = (node) => {
|
|
4186
|
-
if (node.type ===
|
|
4763
|
+
if (node.type === import_utils68.AST_NODE_TYPES.FunctionDeclaration && node.id) {
|
|
4187
4764
|
return node.id.name;
|
|
4188
4765
|
}
|
|
4189
|
-
if (node.type ===
|
|
4766
|
+
if (node.type === import_utils68.AST_NODE_TYPES.FunctionExpression && node.id) {
|
|
4190
4767
|
return node.id.name;
|
|
4191
4768
|
}
|
|
4192
|
-
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) {
|
|
4193
4770
|
return node.parent.id.name;
|
|
4194
4771
|
}
|
|
4195
4772
|
return null;
|
|
4196
4773
|
};
|
|
4197
|
-
var requireExplicitReturnType =
|
|
4774
|
+
var requireExplicitReturnType = createRule59({
|
|
4198
4775
|
name: "require-explicit-return-type",
|
|
4199
4776
|
meta: {
|
|
4200
4777
|
type: "suggestion",
|
|
@@ -4243,8 +4820,8 @@ var requireExplicitReturnType = createRule53({
|
|
|
4243
4820
|
var require_explicit_return_type_default = requireExplicitReturnType;
|
|
4244
4821
|
|
|
4245
4822
|
// src/rules/sort-exports.ts
|
|
4246
|
-
var
|
|
4247
|
-
var
|
|
4823
|
+
var import_utils69 = require("@typescript-eslint/utils");
|
|
4824
|
+
var createRule60 = import_utils69.ESLintUtils.RuleCreator(
|
|
4248
4825
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
4249
4826
|
);
|
|
4250
4827
|
var GROUP_NAMES = ["", "external/alias re-export", "relative re-export", "local export"];
|
|
@@ -4258,7 +4835,7 @@ function getExportGroup(node) {
|
|
|
4258
4835
|
}
|
|
4259
4836
|
return 1;
|
|
4260
4837
|
}
|
|
4261
|
-
var sortExports =
|
|
4838
|
+
var sortExports = createRule60({
|
|
4262
4839
|
name: "sort-exports",
|
|
4263
4840
|
meta: {
|
|
4264
4841
|
type: "suggestion",
|
|
@@ -4298,7 +4875,7 @@ var sortExports = createRule54({
|
|
|
4298
4875
|
Program(node) {
|
|
4299
4876
|
const exportGroups = [];
|
|
4300
4877
|
node.body.forEach((statement) => {
|
|
4301
|
-
if (statement.type !==
|
|
4878
|
+
if (statement.type !== import_utils69.AST_NODE_TYPES.ExportNamedDeclaration || statement.declaration !== null) {
|
|
4302
4879
|
if (exportGroups.length > 0) {
|
|
4303
4880
|
checkOrder(exportGroups);
|
|
4304
4881
|
exportGroups.length = 0;
|
|
@@ -4317,8 +4894,8 @@ var sortExports = createRule54({
|
|
|
4317
4894
|
var sort_exports_default = sortExports;
|
|
4318
4895
|
|
|
4319
4896
|
// src/rules/sort-imports.ts
|
|
4320
|
-
var
|
|
4321
|
-
var
|
|
4897
|
+
var import_utils70 = require("@typescript-eslint/utils");
|
|
4898
|
+
var createRule61 = import_utils70.ESLintUtils.RuleCreator(
|
|
4322
4899
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
4323
4900
|
);
|
|
4324
4901
|
var NODE_BUILTINS = /* @__PURE__ */ new Set([
|
|
@@ -4385,7 +4962,7 @@ function getImportGroup(node) {
|
|
|
4385
4962
|
function isTypeOnlyImport(node) {
|
|
4386
4963
|
return node.importKind === "type" && node.specifiers.length > 0;
|
|
4387
4964
|
}
|
|
4388
|
-
var sortImports =
|
|
4965
|
+
var sortImports = createRule61({
|
|
4389
4966
|
name: "sort-imports",
|
|
4390
4967
|
meta: {
|
|
4391
4968
|
type: "suggestion",
|
|
@@ -4429,7 +5006,7 @@ var sortImports = createRule55({
|
|
|
4429
5006
|
Program(node) {
|
|
4430
5007
|
const importGroups = [];
|
|
4431
5008
|
node.body.forEach((statement) => {
|
|
4432
|
-
if (statement.type !==
|
|
5009
|
+
if (statement.type !== import_utils70.AST_NODE_TYPES.ImportDeclaration) {
|
|
4433
5010
|
if (importGroups.length > 0) {
|
|
4434
5011
|
checkOrder(importGroups);
|
|
4435
5012
|
importGroups.length = 0;
|
|
@@ -4451,13 +5028,13 @@ var sortImports = createRule55({
|
|
|
4451
5028
|
var sort_imports_default = sortImports;
|
|
4452
5029
|
|
|
4453
5030
|
// src/rules/sort-type-alphabetically.ts
|
|
4454
|
-
var
|
|
4455
|
-
var
|
|
5031
|
+
var import_utils71 = require("@typescript-eslint/utils");
|
|
5032
|
+
var createRule62 = import_utils71.ESLintUtils.RuleCreator(
|
|
4456
5033
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
4457
5034
|
);
|
|
4458
5035
|
function isAlphabeticallySortedWithinGroups(members) {
|
|
4459
5036
|
const properties = members.filter(
|
|
4460
|
-
(member) => member.type ===
|
|
5037
|
+
(member) => member.type === import_utils71.AST_NODE_TYPES.TSPropertySignature && member.key.type === import_utils71.AST_NODE_TYPES.Identifier
|
|
4461
5038
|
);
|
|
4462
5039
|
if (properties.length < 2) {
|
|
4463
5040
|
return true;
|
|
@@ -4468,7 +5045,7 @@ function isAlphabeticallySortedWithinGroups(members) {
|
|
|
4468
5045
|
const isOptionalSorted = optional.every((name, index) => index === 0 || optional[index - 1].localeCompare(name) <= 0);
|
|
4469
5046
|
return isRequiredSorted && isOptionalSorted;
|
|
4470
5047
|
}
|
|
4471
|
-
var sortTypeAlphabetically =
|
|
5048
|
+
var sortTypeAlphabetically = createRule62({
|
|
4472
5049
|
name: "sort-type-alphabetically",
|
|
4473
5050
|
meta: {
|
|
4474
5051
|
type: "suggestion",
|
|
@@ -4486,7 +5063,7 @@ var sortTypeAlphabetically = createRule56({
|
|
|
4486
5063
|
function fixMembers(fixer, members) {
|
|
4487
5064
|
const { sourceCode } = context;
|
|
4488
5065
|
const properties = members.filter(
|
|
4489
|
-
(member) => member.type ===
|
|
5066
|
+
(member) => member.type === import_utils71.AST_NODE_TYPES.TSPropertySignature && member.key.type === import_utils71.AST_NODE_TYPES.Identifier
|
|
4490
5067
|
);
|
|
4491
5068
|
const required = properties.filter((prop) => !prop.optional);
|
|
4492
5069
|
const optional = properties.filter((prop) => prop.optional);
|
|
@@ -4523,7 +5100,7 @@ var sortTypeAlphabetically = createRule56({
|
|
|
4523
5100
|
}
|
|
4524
5101
|
},
|
|
4525
5102
|
TSTypeAliasDeclaration(node) {
|
|
4526
|
-
if (node.typeAnnotation.type !==
|
|
5103
|
+
if (node.typeAnnotation.type !== import_utils71.AST_NODE_TYPES.TSTypeLiteral) {
|
|
4527
5104
|
return;
|
|
4528
5105
|
}
|
|
4529
5106
|
const { members } = node.typeAnnotation;
|
|
@@ -4543,13 +5120,13 @@ var sortTypeAlphabetically = createRule56({
|
|
|
4543
5120
|
var sort_type_alphabetically_default = sortTypeAlphabetically;
|
|
4544
5121
|
|
|
4545
5122
|
// src/rules/sort-type-required-first.ts
|
|
4546
|
-
var
|
|
4547
|
-
var
|
|
5123
|
+
var import_utils72 = require("@typescript-eslint/utils");
|
|
5124
|
+
var createRule63 = import_utils72.ESLintUtils.RuleCreator(
|
|
4548
5125
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
4549
5126
|
);
|
|
4550
5127
|
function isRequiredBeforeOptional(members) {
|
|
4551
5128
|
const properties = members.filter(
|
|
4552
|
-
(member) => member.type ===
|
|
5129
|
+
(member) => member.type === import_utils72.AST_NODE_TYPES.TSPropertySignature && member.key.type === import_utils72.AST_NODE_TYPES.Identifier
|
|
4553
5130
|
);
|
|
4554
5131
|
if (properties.length < 2) {
|
|
4555
5132
|
return true;
|
|
@@ -4560,7 +5137,7 @@ function isRequiredBeforeOptional(members) {
|
|
|
4560
5137
|
}
|
|
4561
5138
|
return properties.slice(firstOptionalIndex).every((prop) => prop.optional);
|
|
4562
5139
|
}
|
|
4563
|
-
var sortTypeRequiredFirst =
|
|
5140
|
+
var sortTypeRequiredFirst = createRule63({
|
|
4564
5141
|
name: "sort-type-required-first",
|
|
4565
5142
|
meta: {
|
|
4566
5143
|
type: "suggestion",
|
|
@@ -4578,7 +5155,7 @@ var sortTypeRequiredFirst = createRule57({
|
|
|
4578
5155
|
function fixMembers(fixer, members) {
|
|
4579
5156
|
const { sourceCode } = context;
|
|
4580
5157
|
const properties = members.filter(
|
|
4581
|
-
(member) => member.type ===
|
|
5158
|
+
(member) => member.type === import_utils72.AST_NODE_TYPES.TSPropertySignature && member.key.type === import_utils72.AST_NODE_TYPES.Identifier
|
|
4582
5159
|
);
|
|
4583
5160
|
const required = properties.filter((prop) => !prop.optional);
|
|
4584
5161
|
const optional = properties.filter((prop) => prop.optional);
|
|
@@ -4599,7 +5176,7 @@ var sortTypeRequiredFirst = createRule57({
|
|
|
4599
5176
|
}
|
|
4600
5177
|
},
|
|
4601
5178
|
TSTypeAliasDeclaration(node) {
|
|
4602
|
-
if (node.typeAnnotation.type !==
|
|
5179
|
+
if (node.typeAnnotation.type !== import_utils72.AST_NODE_TYPES.TSTypeLiteral) {
|
|
4603
5180
|
return;
|
|
4604
5181
|
}
|
|
4605
5182
|
const { members } = node.typeAnnotation;
|
|
@@ -4631,14 +5208,18 @@ var rules = {
|
|
|
4631
5208
|
"enforce-property-case": enforce_property_case_default,
|
|
4632
5209
|
"enforce-props-suffix": enforce_props_suffix_default,
|
|
4633
5210
|
"enforce-readonly-component-props": enforce_readonly_component_props_default,
|
|
5211
|
+
"enforce-render-naming": enforce_render_naming_default,
|
|
4634
5212
|
"enforce-service-naming": enforce_service_naming_default,
|
|
4635
5213
|
"enforce-sorted-destructuring": enforce_sorted_destructuring_default,
|
|
4636
5214
|
"enforce-type-declaration-order": enforce_type_declaration_order_default,
|
|
4637
5215
|
"index-export-only": index_export_only_default,
|
|
4638
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,
|
|
4639
5219
|
"jsx-no-inline-object-prop": jsx_no_inline_object_prop_default,
|
|
4640
5220
|
"jsx-no-newline-single-line-elements": jsx_no_newline_single_line_elements_default,
|
|
4641
5221
|
"jsx-no-non-component-function": jsx_no_non_component_function_default,
|
|
5222
|
+
"jsx-no-sub-interface": jsx_no_sub_interface_default,
|
|
4642
5223
|
"jsx-no-ternary-null": jsx_no_ternary_null_default,
|
|
4643
5224
|
"jsx-no-variable-in-callback": jsx_no_variable_in_callback_default,
|
|
4644
5225
|
"jsx-require-suspense": jsx_require_suspense_default,
|
|
@@ -4651,6 +5232,7 @@ var rules = {
|
|
|
4651
5232
|
"no-direct-date": no_direct_date_default,
|
|
4652
5233
|
"no-emoji": no_emoji_default,
|
|
4653
5234
|
"no-env-fallback": no_env_fallback_default,
|
|
5235
|
+
"no-ghost-wrapper": no_ghost_wrapper_default,
|
|
4654
5236
|
"no-inline-default-export": no_inline_default_export_default,
|
|
4655
5237
|
"no-inline-nested-object": no_inline_nested_object_default,
|
|
4656
5238
|
"no-inline-return-properties": no_inline_return_properties_default,
|
|
@@ -4660,6 +5242,7 @@ var rules = {
|
|
|
4660
5242
|
"no-misleading-constant-case": no_misleading_constant_case_default,
|
|
4661
5243
|
"no-nested-interface-declaration": no_nested_interface_declaration_default,
|
|
4662
5244
|
"no-nested-ternary": no_nested_ternary_default,
|
|
5245
|
+
"no-redundant-fragment": no_redundant_fragment_default,
|
|
4663
5246
|
"no-relative-imports": no_relative_imports_default,
|
|
4664
5247
|
"no-single-char-variables": no_single_char_variables_default,
|
|
4665
5248
|
"prefer-async-await": prefer_async_await_default,
|
|
@@ -4773,16 +5356,22 @@ var baseRecommendedRules = {
|
|
|
4773
5356
|
var jsxRules = {
|
|
4774
5357
|
"nextfriday/enforce-props-suffix": "warn",
|
|
4775
5358
|
"nextfriday/enforce-readonly-component-props": "warn",
|
|
5359
|
+
"nextfriday/enforce-render-naming": "warn",
|
|
4776
5360
|
"nextfriday/jsx-newline-between-elements": "warn",
|
|
5361
|
+
"nextfriday/jsx-no-data-array": "warn",
|
|
5362
|
+
"nextfriday/jsx-no-data-object": "warn",
|
|
4777
5363
|
"nextfriday/jsx-no-inline-object-prop": "warn",
|
|
4778
5364
|
"nextfriday/jsx-no-newline-single-line-elements": "warn",
|
|
4779
5365
|
"nextfriday/jsx-no-non-component-function": "warn",
|
|
5366
|
+
"nextfriday/jsx-no-sub-interface": "warn",
|
|
4780
5367
|
"nextfriday/jsx-no-ternary-null": "warn",
|
|
4781
5368
|
"nextfriday/jsx-no-variable-in-callback": "warn",
|
|
4782
5369
|
"nextfriday/jsx-require-suspense": "warn",
|
|
4783
5370
|
"nextfriday/jsx-simple-props": "warn",
|
|
4784
5371
|
"nextfriday/jsx-sort-props": "warn",
|
|
4785
5372
|
"nextfriday/jsx-spread-props-last": "warn",
|
|
5373
|
+
"nextfriday/no-ghost-wrapper": "warn",
|
|
5374
|
+
"nextfriday/no-redundant-fragment": "warn",
|
|
4786
5375
|
"nextfriday/prefer-interface-for-component-props": "warn",
|
|
4787
5376
|
"nextfriday/prefer-interface-over-inline-types": "warn",
|
|
4788
5377
|
"nextfriday/prefer-jsx-template-literals": "warn",
|
|
@@ -4792,16 +5381,22 @@ var jsxRules = {
|
|
|
4792
5381
|
var jsxRecommendedRules = {
|
|
4793
5382
|
"nextfriday/enforce-props-suffix": "error",
|
|
4794
5383
|
"nextfriday/enforce-readonly-component-props": "error",
|
|
5384
|
+
"nextfriday/enforce-render-naming": "error",
|
|
4795
5385
|
"nextfriday/jsx-newline-between-elements": "error",
|
|
5386
|
+
"nextfriday/jsx-no-data-array": "error",
|
|
5387
|
+
"nextfriday/jsx-no-data-object": "error",
|
|
4796
5388
|
"nextfriday/jsx-no-inline-object-prop": "error",
|
|
4797
5389
|
"nextfriday/jsx-no-newline-single-line-elements": "error",
|
|
4798
5390
|
"nextfriday/jsx-no-non-component-function": "error",
|
|
5391
|
+
"nextfriday/jsx-no-sub-interface": "error",
|
|
4799
5392
|
"nextfriday/jsx-no-ternary-null": "error",
|
|
4800
5393
|
"nextfriday/jsx-no-variable-in-callback": "error",
|
|
4801
5394
|
"nextfriday/jsx-require-suspense": "error",
|
|
4802
5395
|
"nextfriday/jsx-simple-props": "error",
|
|
4803
5396
|
"nextfriday/jsx-sort-props": "error",
|
|
4804
5397
|
"nextfriday/jsx-spread-props-last": "error",
|
|
5398
|
+
"nextfriday/no-ghost-wrapper": "error",
|
|
5399
|
+
"nextfriday/no-redundant-fragment": "error",
|
|
4805
5400
|
"nextfriday/prefer-interface-for-component-props": "error",
|
|
4806
5401
|
"nextfriday/prefer-interface-over-inline-types": "error",
|
|
4807
5402
|
"nextfriday/prefer-jsx-template-literals": "error",
|